hitoshura25/cvefixes huggingface dataset:
CVE-2021-37697 (Python, published 2021-08-11T23:15Z)
Description: value: tmerc-cogs are a collection of open source plugins for the Red Discord bot. A vulnerability has been found in the code that allows any user to access sensitive information by crafting a specific membership event message. Issue is patched in commit d63c49b4cfc30c795336e4fff08cba3795e0fcc0. As a workaround users may unload the Welcome cog.
Severity: MEDIUM (CVSS v3 base score: 6.5)
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/tmercswims/tmerc-cogs
Files changed:
welcome/safemodels.py
welcome/welcome.py
Commit message: fix(Welcome): only allow use of safe model attributes


Vulnerable code:
                format_str.format(member=user, server=guild, bot=user, count=count or "", plural=plural, roles=role_str)

Fixed code:
import discord


class SafeMember:
    def __init__(self, member: discord.Member) -> None:
        self.name = str(member.name)
        self.display_name = str(member.display_name)
        self.nick = str(member.nick)
        self.id = str(member.id)
        self.mention = str(member.mention)
        self.discriminator = str(member.discriminator)
        self.color = str(member.color)
        self.colour = str(member.colour)
        self.created_at = str(member.created_at)
        self.joined_at = str(member.joined_at)

    def __str__(self):
        return self.name

    def __getattr__(self, name):
        return self


class SafeRole:
    def __init__(self, role: discord.Role) -> None:
        self.name = str(role.name)
        self.id = str(role.id)
        self.mention = str(role.mention)
        self.color = str(role.color)
        self.colour = str(role.colour)
        self.position = str(role.position)
        self.created_at = str(role.created_at)

    def __str__(self):
        return self.name

    def __getattr__(self, name):
        return self


class SafeGuild:
    def __init__(self, guild: discord.Guild) -> None:
        self.name = str(guild.name)
        self.id = str(guild.id)
        self.description = str(guild.description)
        self.created_at = str(guild.created_at)

    def __str__(self):
        return self.name

    def __getattr__(self, name):
        return self
from .safemodels import SafeGuild, SafeMember
                format_str.format(
                    member=SafeMember(user),
                    server=SafeGuild(guild),
                    bot=SafeMember(user),
                    count=count or "",
                    plural=plural,
                    roles=role_str,
                )
CVE-2014-125026 (Go, published 2022-12-27T22:15Z)
Description: value: LZ4 bindings use a deprecated C API that is vulnerable to memory corruption, which could lead to arbitrary code execution if called with untrusted user input.
Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-787 \u2014 Out-of-bounds Write
The product writes data past the end, or before the beginning, of the intended buffer.
Repository: https://github.com/cloudflare/golz4
Files changed:
lz4.go
Commit message: Use LZ4_decompress_safe instead of LZ4_uncompress

LZ4_uncompress is deprecated and has security problems.


Vulnerable code:
func Uncompress(in, out []byte) (err error) {
	read := int(C.LZ4_uncompress(p(in), p(out), clen(out)))

	if read != len(in) {
		err = fmt.Errorf("uncompress read %d bytes should have read %d",
			read, len(in))
	return

Fixed code:
	"errors"
func Uncompress(in, out []byte) (error) {
	if int(C.LZ4_decompress_safe(p(in), p(out), clen(in), clen(out))) < 0 {
		return errors.New("Malformed compression stream")

	return nil
CVE-2020-15263 (PHP, published 2020-10-19T21:15Z)
Description: value: In platform before version 9.4.4, inline attributes are not properly escaped. If the data that came from users was not escaped, then an XSS vulnerability is possible. The issue was introduced in 9.0.0 and fixed in 9.4.4.
Severity: MEDIUM (CVSS v3 base score: 6.1)
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/orchidsoftware/platform
Files changed:
CHANGELOG.md
src/Platform/Dashboard.php
src/Screen/Field.php
src/Screen/Fields/Upload.php
tests/Unit/Screen/Fields/InputTest.php
Commit message: refs #1313 Escape inline attributes (#1314)



Vulnerable code:
    public const VERSION = '9.4.3';
        $attribute = new ComponentAttributeBag($this->getAttributes());
        return $attribute->filter(function ($value, $attribute) use ($allow) {
            return Str::is($allow, $attribute);
        });
        'value',

Fixed code:
## 9.4.4 - 2020-10-19

### Fixed
- Escape inline attributes [#1313](https://github.com/orchidsoftware/platform/pull/1313)

    public const VERSION = '9.4.4';
        $attributes = collect($this->getAttributes())
            ->filter(function ($value, $attribute) use ($allow) {
                return Str::is($allow, $attribute);
            })->toArray();
        return (new ComponentAttributeBag())
            ->merge($attributes);

    public function testEscapeAttributes(): void
    {
        $input = (string) Input::make('name')->value('valueQuote"');

        $this->assertStringContainsString('value="valueQuote&quot;"', $input);
    }

    public function testRemoveBooleanAttributes(): void
    {
        $input = (string) Input::make('name')->required(false);

        $this->assertStringNotContainsString('required', $input);
    }
CVE-2023-4897 (JavaScript, published 2023-09-11T21:15Z)
Description: value: Relative Path Traversal in GitHub repository mintplex-labs/anything-llm prior to 0.0.1.
Severity: nan (CVSS v3 base score: 9.8)
Weakness: CWE-23 \u2014 Relative Path Traversal
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
frontend/src/components/Modals/MangeWorkspace/Documents/index.jsx
server/endpoints/system.js
Commit message: prevent exports path traversal (#233)



Vulnerable code:
        className={`flex items-center ${canDelete ? "justify-between" : "justify-end"
          } p-4 md:p-6 space-x-2 border-t border-gray-200 rounded-b dark:border-gray-600`}
      const filePath =
        __dirname + "/../storage/exports/" + request.params.filename;
      response.download(filePath, request.params.filename, (err) => {
        response
          .status(500)
          .json({
            success: false,
            message: "Internal server error",
            canDelete: false,
          });

Fixed code:
        className={`flex items-center ${
          canDelete ? "justify-between" : "justify-end"
        } p-4 md:p-6 space-x-2 border-t border-gray-200 rounded-b dark:border-gray-600`}
const fs = require("fs");
      const exportLocation = __dirname + "/../storage/exports/";
      const sanitized = path
        .normalize(request.params.filename)
        .replace(/^(\.\.(\/|\\|$))+/, "");
      const finalDestination = path.join(exportLocation, sanitized);

      if (!fs.existsSync(finalDestination)) {
        response.status(404).json({
          error: 404,
          msg: `File ${request.params.filename} does not exist in exports.`,
        });
        return;
      }

      response.download(finalDestination, request.params.filename, (err) => {
        response.status(500).json({
          success: false,
          message: "Internal server error",
          canDelete: false,
        });
CVE-2023-5832 (Python, published 2023-10-30T13:15Z)
Description: value: Improper Input Validation in GitHub repository mintplex-labs/anything-llm prior to 0.1.0.
Severity: nan (CVSS v3 base score: 9.1)
Weakness: CWE-20 \u2014 Improper Input Validation
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
collector/api.py
Commit message: prevent deletion of documents not in hotdir via director traversal (#258)

resolves #257

Vulnerable code:
  target_filename = content.get('filename')

Fixed code:
import os
  target_filename = os.path.normpath(content.get('filename')).lstrip(os.pardir + os.sep)
CVE-2023-5833 (JavaScript, published 2023-10-30T13:15Z)
Description: value: Improper Access Control in GitHub repository mintplex-labs/anything-llm prior to 0.1.0.
Severity: nan (CVSS v3 base score: 8.8)
Weakness: CWE-284 \u2014 Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/endpoints/system.js
server/utils/helpers/updateENV.js
server/utils/prisma/migrateFromSqlite.js
Commit message: Prevent updates of specific keys via API (#256)

prevent non-admin from updating settings
prevent password updates in multi-user mdoe

Vulnerable code:
        const { error } = updateENV({
          AuthToken: usePassword ? newPassword : "",
          JWTSecret: usePassword ? v4() : "",
        });
        process.env.AUTH_TOKEN = null;
        process.env.JWT_SECRET = process.env.JWT_SECRET ?? v4(); // Make sure JWT_SECRET is set for JWT issuance.
    checks: [],
    checks: [],
function updateENV(newENVs = {}) {
      .map((validityCheck) => validityCheck(value))
  )

Fixed code:

        // Only admins can update the ENV settings.
        if (multiUserMode(response)) {
          const user = await userFromSession(request, response);
          if (!user || user?.role !== "admin") {
            response.sendStatus(401).end();
            return;
          }
        }

        // Cannot update password in multi - user mode.
        if (multiUserMode(response)) {
          response.sendStatus(401).end();
          return;
        }

        const { error } = updateENV(
          {
            AuthToken: usePassword ? newPassword : "",
            JWTSecret: usePassword ? v4() : "",
          },
          true
        );
        if (process.env.NODE_ENV === "production") await dumpENV();

        updateENV(
          {
            AuthToken: null,
            JWTSecret: process.env.JWT_SECRET ?? v4(),
          },
          true
        );
        if (process.env.NODE_ENV === "production") await dumpENV();
    checks: [requiresForceMode],
    checks: [requiresForceMode],
function requiresForceMode(_, forceModeEnabled = false) {
  return forceModeEnabled === true ? null : "Cannot set this setting.";
}

function updateENV(newENVs = {}, force = false) {
      .map((validityCheck) => validityCheck(value, force))
  );
CVE-2024-0404 (JavaScript, published 2024-04-16T00:15Z)
Description: value: A mass assignment vulnerability exists in the `/api/invite/:code` endpoint of the mintplex-labs/anything-llm repository, allowing unauthorized creation of high-privileged accounts. By intercepting and modifying the HTTP request during the account creation process via an invitation link, an attacker can add a `role` property with `admin` value, thereby gaining administrative access. This issue arises due to the lack of property allowlisting and blocklisting, enabling the attacker to exploit the system and perform actions as an administrator.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-915 \u2014 Improperly Controlled Modification of Dynamically-Determined Object Attributes
The product receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/endpoints/invite.js
Commit message: [BUG] Fixed mass_assignment vuln (#566)

Fixed mass_assignment vuln

Co-authored-by: dastaj <78434825+dastaj@users.noreply.github.com>

Vulnerable code:
      const userParams = reqBody(request);
      const { user, error } = await User.create(userParams);

Fixed code:
      const { username, password } = reqBody(request);
      const { user, error } = await User.create(({
        username,
        password,
        role: "default",
      }));
CVE-2024-0435 (JSON, published 2024-02-26T16:27Z)
Description: value: User can send a chat that contains an XSS opportunity that will then run when the chat is sent and on subsequent page loads.

Given the minimum requirement for a user to send a chat is to be given access to a workspace via an admin the risk is low. Additionally, the location in which the XSS renders is only limited to the user who submits the XSS. 

Ultimately, this attack is limited to the user attacking themselves. There is no anonymous chat submission unless the user does not take the minimum steps required to protect their instance.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
frontend/package.json
frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/HistoricalMessage/index.jsx
frontend/yarn.lock
Commit message: Patch minor XSS opportunity where user can self-XSS themselves.  (#574)

Patch minor XSS opportunity where user can self-XSS themselvess. There is not real vuln here as any instance is not public facing

Vulnerable code:
                dangerouslySetInnerHTML={{ __html: renderMarkdown(message) }}

Fixed code:
    "dompurify": "^3.0.8",
import createDOMPurify from "dompurify";
const DOMPurify = createDOMPurify(window);
                dangerouslySetInnerHTML={{
                  __html: DOMPurify.sanitize(renderMarkdown(message)),
                }}
dompurify@^3.0.8:
  version "3.0.8"
  resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.8.tgz#e0021ab1b09184bc8af7e35c7dd9063f43a8a437"
  integrity sha512-b7uwreMYL2eZhrSCRC4ahLTeZcPZxSmYfmcQGXGkXiZSNW1X85v+SDM5KsWcpivIiUBH47Ji7NtyUdpLeF5JZQ==
CVE-2024-0436 (JavaScript, published 2024-02-26T16:27Z)
Description: value: Theoretically, it would be possible for an attacker to brute-force the password for an instance in single-user password protection mode via a timing attack given the linear nature of the `!==` used for comparison.

The risk is minified by the additional overhead of the request, which varies in a non-constant nature making the attack less reliable to execute 
Severity: nan (CVSS v3 base score: )
Weakness: CWE-764 \u2014 Multiple Locks of a Critical Resource
The product locks a critical resource more times than intended, leading to an unexpected state in the system.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
frontend/src/components/Modals/Password/index.jsx
frontend/src/pages/Login/index.jsx
server/endpoints/system.js
server/utils/middleware/validatedRequest.js
Commit message: Change pwd check to O(1) check to prevent timing attacks - single user mode (#575)

Change pwd check to O(1) check to prevent timing attacks

Vulnerable code:
    required: false,
  const { loading, mode } = usePasswordModal();
        const bcrypt = require("bcrypt");
        if (password !== process.env.AUTH_TOKEN) {
  if (p !== process.env.AUTH_TOKEN) {

Fixed code:
    requiresAuth: false,
import { Navigate } from "react-router-dom";
import paths from "@/utils/paths";
  const { loading, requiresAuth, mode } = usePasswordModal();
  if (requiresAuth === false) return <Navigate to={paths.home()} />;

      const bcrypt = require("bcrypt");

        if (
          !bcrypt.compareSync(
            password,
            bcrypt.hashSync(process.env.AUTH_TOKEN, 10)
          )
        ) {
  const bcrypt = require("bcrypt");
  if (!bcrypt.compareSync(p, bcrypt.hashSync(process.env.AUTH_TOKEN, 10))) {
CVE-2024-0439 (JavaScript, published 2024-02-26T16:27Z)
Description: value: As a manager, you should not be able to modify a series of settings. In the UI this is indeed hidden as a convenience for the role since most managers would not be savvy enough to modify these settings. They can use their token to still modify those settings though through a standard HTTP request

While this is not a critical vulnerability, it does indeed need to be patched to enforce the expected permission level.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-269 \u2014 Improper Privilege Management
The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/endpoints/system.js
server/utils/http/index.js
Commit message: prevent manager in multi-user from updatingENV via HTTP (#576)

* prevent manager in multi-user from updatingENV via HTTP

* remove unneeded args

Vulnerable code:

Fixed code:
        const user = await userFromSession(request, response);
        if (!!user && user.role !== "admin") {
          response.sendStatus(401).end();
          return;
        }

// Note: Only valid for finding users in multi-user mode
// as single-user mode with password is not a "user"
CVE-2024-0440 (JavaScript, published 2024-02-26T16:27Z)
Description: value: Attacker, with permission to submit a link or submits a link via POST  to be collected that is using the file:// protocol can then introspect host files and other relatively stored files.
Severity: nan (CVSS v3 base score: )
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
collector/utils/url/index.js
Commit message: Strict link protocol validation (#577)



Vulnerable code:
    new URL(url);

Fixed code:
const VALID_PROTOCOLS = ["https:", "http:"];

    const destination = new URL(url);
    if (!VALID_PROTOCOLS.includes(destination.protocol)) return false;
CVE-2024-0455 (JSON, published 2024-02-26T16:27Z)
Description: value: The inclusion of the web scraper for AnythingLLM means that any user with the proper authorization level (manager, admin, and when in single user) could put in the URL
```
http://169.254.169.254/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance
```
which is a special IP and URL that resolves only when the request comes from within an EC2 instance. This would allow the user to see the connection/secret credentials for their specific instance and be able to manage it regardless of who deployed it.

The user would have to have pre-existing knowledge of the hosting infra which the target instance is deployed on, but if sent - would resolve if on EC2 and the proper `iptable` or firewall rule is not configured for their setup.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-918 \u2014 Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
cloud-deployments/aws/cloudformation/cloudformation_create_anythingllm.json
Commit message: protect AWS CF deployments by automatically blocking metadata URL (#578)



Vulnerable code:
                "sudo yum install docker -y\n",

Fixed code:
                "sudo yum install docker iptables -y\n",
                "sudo iptables -A OUTPUT -m owner ! --uid-owner root -d 169.254.169.254 -j DROP\n",
CVE-2024-0550 (JavaScript, published 2024-02-28T05:15Z)
Description: value: A user who is privileged already `manager` or `admin` can set their profile picture via the frontend API using a relative filepath to then user the PFP GET API to download any valid files.

The attacker would have to have been granted privileged permissions to the system before executing this attack.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-23 \u2014 Relative Path Traversal
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize sequences such as ".." that can resolve to a location that is outside of that directory.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/endpoints/system.js
server/utils/files/pfp.js
Commit message: Normalize pfp path to prevent traversal


Vulnerable code:
        const oldPfpFilename = userRecord.pfpFilename;
        const oldPfpFilename = userRecord.pfpFilename;
  const pfpFilepath = path.join(basePath, pfpFilename);


Fixed code:
        const oldPfpFilename = normalizePath(userRecord.pfpFilename);

        const oldPfpFilename = normalizePath(userRecord.pfpFilename);
const { normalizePath } = require(".");
  const pfpFilepath = path.join(basePath, normalizePath(pfpFilename));
CVE-2024-0551 (JavaScript, published 2024-02-27T14:15Z)
Description: value: Enable exports of the database and associated exported information of the system via the default user role. The attacked would have to have been granted access to the system prior to the attack.

It is worth noting that the deterministic nature of the export name is lower risk as the UI for exporting would start the download at the same time, which once downloaded - deletes the export from the system.

The endpoint for exporting should simply be patched to a higher privilege level.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-284 \u2014 Improper Access Control
The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/endpoints/system.js
Commit message: add flex role to export endpoint


Vulnerable code:
  app.get("/system/data-export", [validatedRequest], async (_, response) => {
    try {
      const { filename, error } = await exportData();
      response.status(200).json({ filename, error });
    } catch (e) {
      console.log(e.message, e);
      response.sendStatus(500).end();
  });

Fixed code:
  app.get(
    "/system/data-export",
    [validatedRequest, flexUserRoleValid],
    async (_, response) => {
      try {
        const { filename, error } = await exportData();
        response.status(200).json({ filename, error });
      } catch (e) {
        console.log(e.message, e);
        response.sendStatus(500).end();
      }
  );