Skip to content

Fix critical security issues: command injection, wildcard CORS, SSRF#2

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1782584026-security-fixes
Open

Fix critical security issues: command injection, wildcard CORS, SSRF#2
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1782584026-security-fixes

Conversation

@devin-ai-integration

Copy link
Copy Markdown

What changes were proposed in this pull request?

This PR fixes three security vulnerabilities found during a codebase audit:

1. CSI NodeService — Command Injection (Critical)

NodeService.executeCommand() used Runtime.getRuntime().exec(String) which tokenizes via StringTokenizer, and nodeUnpublishVolume / nodePublishVolume interpolated unvalidated gRPC request fields (volumeId, targetPath) directly into shell command strings via String.format().

Fix:

  • Replace Runtime.exec(String) with ProcessBuilder(List<String>) for explicit argument separation (no shell interpretation).
  • Add validatePath() that rejects paths not matching ^[a-zA-Z0-9/_\\:. -]+$ and catches InvalidPathException, applied to both targetPath and volumeId before use.

2. ProfileServlet — Wildcard CORS (Medium-High)

setResponseHeader() set Access-Control-Allow-Origin: *, allowing any website to make cross-origin requests to the async-profiler endpoint. This could expose JVM profiling data to untrusted origins.

Fix: Remove the Access-Control-Allow-Origin: * header entirely. The profiling endpoint is an internal management tool and should not be accessible cross-origin.

3. MetricsProxyEndpoint — SSRF via Path Traversal (Medium)

The {api} @PathParam in GET /api/v1/metrics/{api} was passed to PrometheusServiceProviderImpl.getMetricsResponse() which interpolated it into a URL via String.format("%s/api/v1/%s?%s", ...) without validation. A crafted api value like ../../admin/tsdb could reach arbitrary Prometheus endpoints.

Fix: Validate api against ^[a-zA-Z0-9_]+$ and return 400 Bad Request for non-matching values.

What is the link to the Apache JIRA

No JIRA — this is a fork-level security hardening PR.

How was this patch tested?

  • Full Maven build (mvn clean install -DskipTests -DskipShade -DskipRecon -DskipDocs) passes.
  • Manual review of all three changed files to verify correctness.
  • Existing TestProfileServlet does not reference the removed CORS header.

Generated-by: Devin (Claude)

Link to Devin session: https://app.devin.ai/sessions/56da5ad1fcfd44a0a984cf13ee9a426c
Requested by: @marcuslin123

- CSI NodeService: Replace Runtime.exec(String) with ProcessBuilder(List)
  to avoid shell metacharacter interpretation. Add input validation
  (regex allowlist + InvalidPathException check) for volumeId and
  targetPath from gRPC requests before passing to mount/unmount commands.

- ProfileServlet: Remove Access-Control-Allow-Origin: * header that allowed
  any origin to access the async-profiler endpoint, exposing JVM profiling
  data to cross-origin requests.

- MetricsProxyEndpoint: Validate the {api} path parameter against
  ^[a-zA-Z0-9_]+$ before interpolating it into the Prometheus URL,
  preventing path traversal to arbitrary Prometheus endpoints.

Generated-by: Devin (Claude)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@marcuslin123 marcuslin123 self-assigned this Jun 27, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant