CVE-2024-47171: Agnai Path Traversal Vulnerability

LOW
Advisory Identifier: GHSA-g54f-66mw-hv66
CVSS 4.3
CWE-35 CWE-22
Published
Advisory Summary

CVE-2024-47171 is a LOW (CVSS 4.3) path traversal vulnerability (CWE-35: Path Traversal: '.../...//') affecting Agnai libraries in the npm ecosystem. The issue involves agnai vulnerable to relative path traversal in image upload. Remediation is available by upgrading affected packages to version 1.0.330.

CVE-2024-47171 at a Glance

CVE Identifier CVE-2024-47171
GHSA Identifier GHSA-g54f-66mw-hv66
Severity LOW
CVSS v3.1 Base Score 4.3
CWE Classification CWE-35: Path Traversal: '.../...//'
Affected Product Agnai
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2024-47171

To remediate this vulnerability, upgrade all affected Agnai dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

agnai fixed: 1.0.330
npm install agnai@1.0.330
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls agnai

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-47171, inspect your project dependencies using npm:

npm ls agnai

Analyze the terminal output to locate any version of Agnai in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.330), your application is affected.

Note: The npm ls agnai command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-35: Path Traversal: '.../...//', where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '.../...//' (doubled triple dot slash) sequences that can resolve to a location that is outside of that directory. In Agnai, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A vulnerability has been discovered in **Agnai** that permits attackers to upload image files at attacker-chosen location on the server. This issue can lead to image file uploads to unauthorized or unintended directories, including overwriting of existing images which may be used for defacement. This does not affect: - agnai.chat - installations using S3-compatible storage - self-hosting that is not publicly exposed ### CWE-35: Path Traversal https://cwe.mitre.org/data/definitions/35.html ### CVSS4.0 - 2.3 Low CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N ### Details This is a path traversal vulnerability. An attacker can exploit this vulnerability by sending a specially crafted request to the `editCharacter` handler https://github.com/agnaistic/agnai/blob/75abbd5b0f5e48ddecc805365cf1574d05ee1ce5/srv/api/character.ts#L140: ```tsx POST /api/character/28cbe508-2fa9-4890-886e-61d73e22006c%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%61%70%70%2f%64%69%73%74%2f%64%61%6e%79%61%6e%67 HTTP/1.1 ``` The path traversal character sequence makes it’s way into the `id` variable which is then string interpolated into `filename`. ```jsx export async function entityUpload(kind: string, id: string, attachment?: Attachment) { if (!attachment) return const filename = `${kind}-${id}` return upload(attachment, filename) } ``` https://github.com/agnaistic/agnai/blob/75abbd5b0f5e48ddecc805365cf1574d05ee1ce5/srv/api/upload.ts#L55 No path normalization is conducted nor checked, so attackers can freely manipulate the path which the file is uploaded to. ### Impact This vulnerability is classified as a path traversal vulnerability. Attackers can upload image files to arbitrary locations, potentially overwriting critical system image files. ### Credit Security research in collaboration with Analyst [Danyang Liu (noe223)](https://github.com/noe233) @noe233

CVE-2024-47171 Affected Agnai Versions

1 component(s)
Fixed Versions:
1.0.330
Product / Package Ecosystem Affected Versions Fixed Version
agnai
npm
< 1.0.330
1.0.330

References

Frequently Asked Questions

What is CVE-2024-47171?
CVE-2024-47171 is a security vulnerability in Agnai involving Agnai vulnerable to Relative Path Traversal in Image Upload under CWE-35: Path Traversal: '.../...//'.
Which Agnai versions are affected?
Affected versions include releases prior to 1.0.330 across affected packages: agnai.
What version fixes CVE-2024-47171?
Upgrading to 1.0.330 (or the latest patched release for your respective branch) resolves the vulnerability.
Is agnai affected?
Yes, agnai is affected in releases prior to 1.0.330. Upgrade your dependency to 1.0.330 or later.
What is the CVSS score of CVE-2024-47171?
CVE-2024-47171 has a CVSS v3.1 base score of 4.3 (LOW) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2024-47171?
CVE-2024-47171 is classified under CWE-35: Path Traversal: '.../...//' (The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize '.../...//' (doubled triple dot slash) sequences that can resolve to a location that is outside of that directory.).
How can I check npm dependencies for CVE-2024-47171?
Run the dependency tree command: 'npm ls agnai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-g54f-66mw-hv66",
  "modified" : "2024-09-26T21:11:07Z",
  "published" : "2024-09-26T18:16:13Z",
  "aliases" : [ "CVE-2024-47171" ],
  "summary" : "Agnai vulnerable to Relative Path Traversal in Image Upload",
  "details" : "### Summary\n\nA vulnerability has been discovered in **Agnai** that permits attackers to upload image files at attacker-chosen location on the server. This issue can lead to image file uploads to unauthorized or unintended directories, including overwriting of existing images which may be used for defacement.\n\nThis does not affect:\n\n- agnai.chat\n- installations using S3-compatible storage\n- self-hosting that is not publicly exposed\n\n### CWE-35: Path Traversal\n\nhttps://cwe.mitre.org/data/definitions/35.html\n\n### CVSS4.0 - 2.3 Low\n\nCVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N\n\n### Details\n\nThis is a path traversal vulnerability. An attacker can exploit this vulnerability by sending a specially crafted request to the `editCharacter` handler https://github.com/agnaistic/agnai/blob/75abbd5b0f5e48ddecc805365cf1574d05ee1ce5/srv/api/character.ts#L140:\n\n```tsx\nPOST /api/character/28cbe508-2fa9-4890-886e-61d73e22006c%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%61%70%70%2f%64%69%73%74%2f%64%61%6e%79%61%6e%67 HTTP/1.1\n```\n\nThe path traversal character sequence makes it’s way into the `id` variable which is then string interpolated into `filename`. \n\n```jsx\nexport async function entityUpload(kind: string, id: string, attachment?: Attachment) {\n  if (!attachment) return\n  const filename = `${kind}-${id}`\n  return upload(attachment, filename)\n}\n```\n\nhttps://github.com/agnaistic/agnai/blob/75abbd5b0f5e48ddecc805365cf1574d05ee1ce5/srv/api/upload.ts#L55\n\nNo path normalization is conducted nor checked, so attackers can freely manipulate the path which the file is uploaded to.\n\n### Impact\n\nThis vulnerability is classified as a path traversal vulnerability. Attackers can upload image files to arbitrary locations, potentially overwriting critical system image files.\n\n### Credit\nSecurity research in collaboration with Analyst [Danyang Liu (noe223)](https://github.com/noe233) @noe233",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "agnai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.330"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/agnaistic/agnai/security/advisories/GHSA-g54f-66mw-hv66"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-47171"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/agnaistic/agnai"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agnaistic/agnai/blob/75abbd5b0f5e48ddecc805365cf1574d05ee1ce5/srv/api/character.ts#L140:"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/agnaistic/agnai/blob/75abbd5b0f5e48ddecc805365cf1574d05ee1ce5/srv/api/upload.ts#L55"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-35" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-26T18:16:13Z",
    "nvd_published_at" : "2024-09-26T18:15:10Z"
  }
}