Skip to content

SEC: Arbitrary File Write via Credential Injection Parameter Tampering #183

Closed

Description

@vybe

Pentest Finding 3.2.6 — Medium (CVSS 4.8)

CVSS Vector: CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N

Location: POST /api/agents/{name}/credentials/inject

Impact

An authenticated user can supply any file path in the files map, causing the server to write attacker-controlled content to arbitrary filesystem locations inside the agent container. This can lead to configuration overrides or persistent code execution.

Steps to Reproduce

POST /api/agents/shared/credentials/inject
{"files":{"/hello/anyfile.html":"<img src onerror=prompt(11)>"}}
# Returns 200 OK
# {"status":"success","files_written":["/hello/anyfile.html"]}

The server creates arbitrary directories and files with attacker-controlled content instead of restricting to predefined credential file paths.

Remediation

  • Define an allowlist of valid credential file paths (e.g., .env, .mcp.json)
  • Reject any file path not in the allowlist
  • Use readOnly property in schemas for properties that should never be modified
  • Precisely define schemas, types, and patterns accepted in requests and enforce at runtime
  • Do not automatically bind incoming data and internal objects

References

Source: UnderDefense Web Pentest Report, March 2026

Metadata

Metadata

Assignees

No one assigned

    Labels

    pentestpriority-p1securityseverity-medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions