hitoshura25/cvefixes huggingface dataset:
CVE-2024-0759 (JavaScript, published 2024-02-27T06:15Z)
Description: value: Should an instance of AnythingLLM be hosted on an internal network and the attacked be explicitly granted a permission level of manager or admin, they could link-scrape internally resolving IPs of other services that are on the same network as AnythingLLM.

This would require the attacker also be able to guess these internal IPs as `/*` ranging is not possible, but could be brute forced.

There is a duty of care that other services on the same network would not be fully open and accessible via a simple CuRL with zero authentication as it is not possible to set headers or access via the link collector.
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:
collector/utils/url/index.js
server/endpoints/system.js
Commit message: Prevent private octets from link collection for self-hosted (#626)



Vulnerable code:
const {
  setupLogoUploads,
  setupPfpUploads,
} = require("../utils/files/multer");

Fixed code:
const INVALID_OCTETS = [192, 172, 10, 127];

function isInvalidIp({ hostname }) {
  const IPRegex = new RegExp(
    /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gi
  );
  if (!IPRegex.test(hostname)) return false;
  const [octetOne, ..._rest] = hostname.split(".");

  // If fails to validate to number - abort and return as invalid.
  if (isNaN(Number(octetOne))) return true;
  return INVALID_OCTETS.includes(Number(octetOne));
}
    if (isInvalidIp(destination)) return false;
const { setupLogoUploads, setupPfpUploads } = require("../utils/files/multer");
CVE-2024-0798 (JavaScript, published 2024-02-26T16:27Z)
Description: value: A privilege escalation vulnerability exists in mintplex-labs/anything-llm, allowing users with 'default' role to delete documents uploaded by 'admin'. Despite the intended restriction that prevents 'default' role users from deleting admin-uploaded documents, an attacker can exploit this vulnerability by sending a crafted DELETE request to the /api/system/remove-document endpoint. This vulnerability is due to improper access control checks, enabling unauthorized document deletion and potentially leading to loss of data integrity.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-272 \u2014 Least Privilege Violation
The elevated privilege level required to perform operations such as chroot() should be dropped immediately after the operation is performed.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/endpoints/system.js
Commit message: Apply permissioning on document modification endpoints (#637)



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

Fixed code:
    [validatedRequest, flexUserRoleValid([ROLES.admin, ROLES.manager])],
    [validatedRequest, flexUserRoleValid([ROLES.admin, ROLES.manager])],
    [validatedRequest, flexUserRoleValid([ROLES.admin, ROLES.manager])],
  app.get(
    "/system/local-files",
    [validatedRequest, flexUserRoleValid([ROLES.admin, ROLES.manager])],
    async (_, response) => {
      try {
        const localFiles = await viewLocalFiles();
        response.status(200).json({ localFiles });
      } catch (e) {
        console.log(e.message, e);
        response.sendStatus(500).end();
      }
  );
CVE-2024-3025 (JavaScript, published 2024-04-10T17:15Z)
Description: value: mintplex-labs/anything-llm is vulnerable to path traversal attacks due to insufficient validation of user-supplied input in the logo filename functionality. Attackers can exploit this vulnerability by manipulating the logo filename to reference files outside of the restricted directory. This can lead to unauthorized reading or deletion of files by utilizing the `/api/system/upload-logo` and `/api/system/logo` endpoints. The issue stems from the lack of filtering or validation on the logo filename, allowing attackers to target sensitive files such as the application's database.
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/utils/files/logo.js
Commit message: norm path logo


Vulnerable code:
    customLogoPath = path.join(basePath, currentLogoFilename);
    ? path.join(process.env.STORAGE_DIR, "assets", originalFilename)
    : path.join(__dirname, `../../storage/assets/${originalFilename}`);
    ? path.join(process.env.STORAGE_DIR, "assets", newFilename)
    : path.join(__dirname, `../../storage/assets/${newFilename}`);
    ? path.join(process.env.STORAGE_DIR, `assets/${logoFilename}`)
    : path.join(__dirname, `../../storage/assets/${logoFilename}`);

Fixed code:
const { normalizePath } = require(".");
    customLogoPath = path.join(basePath, normalizePath(currentLogoFilename));
    ? path.join(process.env.STORAGE_DIR, "assets", normalizePath(originalFilename))
    : path.join(__dirname, `../../storage/assets`, normalizePath(originalFilename));
    ? path.join(process.env.STORAGE_DIR, "assets", normalizePath(newFilename))
    : path.join(__dirname, `../../storage/assets`, normalizePath(newFilename));
    ? path.join(process.env.STORAGE_DIR, `assets`, normalizePath(logoFilename))
    : path.join(__dirname, `../../storage/assets`, normalizePath(logoFilename));
CVE-2024-3028 (JavaScript, published 2024-04-16T00:15Z)
Description: value: mintplex-labs/anything-llm is vulnerable to improper input validation, allowing attackers to read and delete arbitrary files on the server. By manipulating the 'logo_filename' parameter in the 'system-preferences' API endpoint, an attacker can construct requests to read sensitive files or the application's '.env' file, and even delete files by setting the 'logo_filename' to the path of the target file and invoking the 'remove-logo' API endpoint. This vulnerability is due to the lack of proper sanitization of user-supplied input.
Severity: nan (CVSS v3 base score: )
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:
server/utils/files/logo.js
Commit message: norm path logo


Vulnerable code:
    customLogoPath = path.join(basePath, currentLogoFilename);
    ? path.join(process.env.STORAGE_DIR, "assets", originalFilename)
    : path.join(__dirname, `../../storage/assets/${originalFilename}`);
    ? path.join(process.env.STORAGE_DIR, "assets", newFilename)
    : path.join(__dirname, `../../storage/assets/${newFilename}`);
    ? path.join(process.env.STORAGE_DIR, `assets/${logoFilename}`)
    : path.join(__dirname, `../../storage/assets/${logoFilename}`);

Fixed code:
const { normalizePath } = require(".");
    customLogoPath = path.join(basePath, normalizePath(currentLogoFilename));
    ? path.join(process.env.STORAGE_DIR, "assets", normalizePath(originalFilename))
    : path.join(__dirname, `../../storage/assets`, normalizePath(originalFilename));
    ? path.join(process.env.STORAGE_DIR, "assets", normalizePath(newFilename))
    : path.join(__dirname, `../../storage/assets`, normalizePath(newFilename));
    ? path.join(process.env.STORAGE_DIR, `assets`, normalizePath(logoFilename))
    : path.join(__dirname, `../../storage/assets`, normalizePath(logoFilename));
CVE-2024-3029 (JavaScript, published 2024-04-16T00:15Z)
Description: value: In mintplex-labs/anything-llm, an attacker can exploit improper input validation by sending a malformed JSON payload to the '/system/enable-multi-user' endpoint. This triggers an error that is caught by a catch block, which in turn deletes all users and disables the 'multi_user_mode'. The vulnerability allows an attacker to remove all existing users and potentially create a new admin user without requiring a password, leading to unauthorized access and control over the application.
Severity: nan (CVSS v3 base score: )
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:
server/endpoints/system.js
Commit message: sec: fix enable-multi-user preflight check to prevent error loop


Vulnerable code:
        const { username, password } = reqBody(request);
        const multiUserModeEnabled = await SystemSettings.isMultiUserMode();
        if (multiUserModeEnabled) {

Fixed code:
        if (response.locals.multiUserMode) {
        const { username, password } = reqBody(request);
CVE-2024-3033 (JavaScript, published 2024-06-06T18:15Z)
Description: value: An improper authorization vulnerability exists in the mintplex-labs/anything-llm application, specifically within the '/api/v/' endpoint and its sub-routes. This flaw allows unauthenticated users to perform destructive actions on the VectorDB, including resetting the database and deleting specific namespaces, without requiring any authorization or permissions. The issue affects all versions up to and including the latest version, with a fix introduced in version 1.0.0. Exploitation of this vulnerability can lead to complete data loss of document embeddings across all workspaces, rendering workspace chats and embeddable chat widgets non-functional. Additionally, attackers can list all namespaces, potentially exposing private workspace names.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-285 \u2014 Improper Authorization
The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/index.js
Commit message: move vector db debug endpoint to dev only


Vulnerable code:
apiRouter.post("/v/:command", async (request, response) => {
  try {
    const VectorDb = getVectorDbClass();
    const { command } = request.params;
    if (!Object.getOwnPropertyNames(VectorDb).includes(command)) {
      response.status(500).json({
        message: "invalid interface command",
        commands: Object.getOwnPropertyNames(VectorDb),
      });
      return;
    }

    try {
      const body = reqBody(request);
      const resBody = await VectorDb[command](body);
      response.status(200).json({ ...resBody });
    } catch (e) {
      // console.error(e)
      console.error(JSON.stringify(e));
      response.status(500).json({ error: e.message });
    }
    return;
  } catch (e) {
    console.log(e.message, e);
    response.sendStatus(500).end();
  }
});


Fixed code:
} else {
  // Debug route for development connections to vectorDBs
  apiRouter.post("/v/:command", async (request, response) => {
    try {
      const VectorDb = getVectorDbClass();
      const { command } = request.params;
      if (!Object.getOwnPropertyNames(VectorDb).includes(command)) {
        response.status(500).json({
          message: "invalid interface command",
          commands: Object.getOwnPropertyNames(VectorDb),
        });
        return;
      }

      try {
        const body = reqBody(request);
        const resBody = await VectorDb[command](body);
        response.status(200).json({ ...resBody });
      } catch (e) {
        // console.error(e)
        console.error(JSON.stringify(e));
        response.status(500).json({ error: e.message });
      }
      return;
    } catch (e) {
      console.log(e.message, e);
      response.sendStatus(500).end();
    }
  });
CVE-2024-3102 (JavaScript, published 2024-06-06T19:15Z)
Description: value: A JSON Injection vulnerability exists in the `mintplex-labs/anything-llm` application, specifically within the username parameter during the login process at the `/api/request-token` endpoint. The vulnerability arises from improper handling of values, allowing attackers to perform brute force attacks without prior knowledge of the username. Once the password is known, attackers can conduct blind attacks to ascertain the full username, significantly compromising system security.
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:
server/endpoints/system.js
Commit message: security: patch primsa expansion on token request


Vulnerable code:
        const existingUser = await User.get({ username });
        if (!bcrypt.compareSync(password, existingUser.password)) {

Fixed code:
        const existingUser = await User.get({ username: String(username) });
        if (!bcrypt.compareSync(String(password), existingUser.password)) {
CVE-2024-3104 (JavaScript, published 2024-06-06T18:15Z)
Description: value: A remote code execution vulnerability exists in mintplex-labs/anything-llm due to improper handling of environment variables. Attackers can exploit this vulnerability by injecting arbitrary environment variables via the `POST /api/system/update-env` endpoint, which allows for the execution of arbitrary code on the host running anything-llm. The vulnerability is present in the latest version of anything-llm, with the latest commit identified as fde905aac1812b84066ff72e5f2f90b56d4c3a59. This issue has been fixed in version 1.0.0. Successful exploitation could lead to code execution on the host, enabling attackers to read and modify data accessible to the user running the service, potentially leading to a denial of service. 
Severity: nan (CVSS v3 base score: )
Weakness: CWE-78 \u2014 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
server/utils/helpers/updateENV.js
Commit message: security: force sanitize env string set by user


Vulnerable code:
    .map(([key, value]) => {
      return `${key}='${value}'`;
    })

Fixed code:
  // Simple sanitization of each value to prevent ENV injection via newline or quote escaping.
  function sanitizeValue(value) {
    const offendingChars =
      /[\n\r\t\v\f\u0085\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000"'`#]/;
    const firstOffendingCharIndex = value.search(offendingChars);
    if (firstOffendingCharIndex === -1) return value;

    return value.substring(0, firstOffendingCharIndex);
  }

    .map(([key, value]) => `${key}='${sanitizeValue(value)}'`)
CVE-2024-3110 (JavaScript, published 2024-06-06T19:15Z)
Description: value: A stored Cross-Site Scripting (XSS) vulnerability exists in the mintplex-labs/anything-llm application, affecting versions up to and including the latest before 1.0.0. The vulnerability arises from the application's failure to properly sanitize and validate user-supplied URLs before embedding them into the application UI as external links with custom icons. Specifically, the application does not prevent the inclusion of 'javascript:' protocol payloads in URLs, which can be exploited by a user with manager role to execute arbitrary JavaScript code in the context of another user's session. This flaw can be leveraged to steal the admin's authorization token by crafting malicious URLs that, when clicked by the admin, send the token to an attacker-controlled server. The attacker can then use this token to perform unauthorized actions, escalate privileges to admin, or directly take over the admin account. The vulnerability is triggered when the malicious link is opened in a new tab using either the CTRL + left mouse button click or the mouse scroll wheel click, or in some non-updated versions of modern browsers, by directly clicking on the link.
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:
server/models/systemSettings.js
server/utils/http/index.js
Commit message: security: patch footer icon self-xss from privledged user


Vulnerable code:
        const array = JSON.parse(updates);
        return JSON.stringify(array.slice(0, 3)); // max of 3 items in footer.

Fixed code:
const { isValidUrl } = require("../utils/http");
        const array = JSON.parse(updates)
          .filter((setting) => isValidUrl(setting.url))
          .slice(0, 3); // max of 3 items in footer.
        return JSON.stringify(array);
function isValidUrl(urlString = "") {
  try {
    const url = new URL(urlString);
    if (!["http:", "https:"].includes(url.protocol)) return false;
    return true;
  } catch (e) {}
  return false;
}

  isValidUrl,
CVE-2024-3150 (JavaScript, published 2024-06-06T19:16Z)
Description: value: In mintplex-labs/anything-llm, a vulnerability exists in the thread update process that allows users with Default or Manager roles to escalate their privileges to Administrator. The issue arises from improper input validation when handling HTTP POST requests to the endpoint `/workspace/:slug/thread/:threadSlug/update`. Specifically, the application fails to validate or check user input before passing it to the `workspace_thread` Prisma model for execution. This oversight allows attackers to craft a Prisma relation query operation that manipulates the `users` model to change a user's role to admin. Successful exploitation grants attackers the highest level of user privileges, enabling them to see and perform all actions within the system.
Severity: nan (CVSS v3 base score: )
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:
server/models/workspaceThread.js
Commit message: patch prisma query expansion on threads


Vulnerable code:
    const validKeys = Object.keys(data).filter((key) =>
      this.writable.includes(key)
    );
    if (validKeys.length === 0)
        data,

Fixed code:
    const validData = {};
    Object.entries(data).forEach(([key, value]) => {
      if (!this.writable.includes(key)) return;
      validData[key] = value;
    });

    if (Object.keys(validData).length === 0)
        data: validData,
CVE-2024-3152 (JavaScript, published 2024-06-06T18:15Z)
Description: value: mintplex-labs/anything-llm is vulnerable to multiple security issues due to improper input validation in several endpoints. An attacker can exploit these vulnerabilities to escalate privileges from a default user role to an admin role, read and delete arbitrary files on the system, and perform Server-Side Request Forgery (SSRF) attacks. The vulnerabilities are present in the `/request-token`, `/workspace/:slug/thread/:threadSlug/update`, `/system/remove-logo`, `/system/logo`, and collector's `/process` endpoints. These issues are due to the application's failure to properly validate user input before passing it to `prisma` functions and other critical operations. Affected versions include the latest version prior to 1.0.0.
Severity: nan (CVSS v3 base score: )
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:
server/models/workspaceThread.js
Commit message: patch prisma query expansion on threads


Vulnerable code:
    const validKeys = Object.keys(data).filter((key) =>
      this.writable.includes(key)
    );
    if (validKeys.length === 0)
        data,

Fixed code:
    const validData = {};
    Object.entries(data).forEach(([key, value]) => {
      if (!this.writable.includes(key)) return;
      validData[key] = value;
    });

    if (Object.keys(validData).length === 0)
        data: validData,
CVE-2024-3569 (Other, published 2024-04-10T17:15Z)
Description: value: A Denial of Service (DoS) vulnerability exists in the mintplex-labs/anything-llm repository when the application is running in 'just me' mode with a password. An attacker can exploit this vulnerability by making a request to the endpoint using the [validatedRequest] middleware with a specially crafted 'Authorization:' header. This vulnerability leads to uncontrolled resource consumption, causing a DoS condition.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-400 \u2014 Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
Repository: https://github.com/mintplex-labs/anything-llm
Files changed:
frontend/src/components/Modals/Password/index.jsx
frontend/src/components/PrivateRoute/index.jsx
frontend/src/pages/Login/index.jsx
frontend/src/utils/paths.js
server/utils/middleware/validatedRequest.js
Commit message: handle expired token being null and prevent constant rerender (#956)

* handle expired token being null and prevent constant rerender

* reset defaults

Vulnerable code:
export function usePasswordModal() {
      if (!System.needsAuthCheck()) {
          const valid = await System.checkAuth(currentToken);
          const valid = await System.checkAuth(currentToken);
    <Navigate to={paths.login()} />
  const { loading, requiresAuth, mode } = usePasswordModal();
  login: () => {
    return "/login";
      error: "Invalid auth token found.",

Fixed code:
export function usePasswordModal(notry = false) {
      if (!System.needsAuthCheck() && notry === false) {
          const valid = notry ? false : await System.checkAuth(currentToken);
          const valid = notry ? false : await System.checkAuth(currentToken);
            window.localStorage.removeItem(AUTH_USER);
            window.localStorage.removeItem(AUTH_TIMESTAMP);
    <Navigate to={paths.login(true)} />
import useQuery from "@/hooks/useQuery";
  const query = useQuery();
  const { loading, requiresAuth, mode } = usePasswordModal(!!query.get("nt"));
  login: (noTry = false) => {
    return `/login${noTry ? "?nt=1" : ""}`;

  if (p === null) {
    response.status(401).json({
      error: "Token expired or failed validation.",
    });
    return;
  }

      error: "Invalid auth credentials.",