Skip to content

🛡️ Sentinel: [HIGH] Sanitize UploadInfo.getFileName() to prevent path traversal - #153

Merged
tomdesair merged 1 commit into
bugfix/cloud-robustness-security-performancefrom
bugfix/sanitize-uploadinfo-filename
Nov 15, 2026
Merged

tomdesair merged 1 commit into
bugfix/cloud-robustness-security-performancefrom
bugfix/sanitize-uploadinfo-filename

Conversation

@tomdesair

Copy link
Copy Markdown
Owner

Severity

HIGH

Vulnerability

Path Traversal (CWE-22) and Null-Byte Injection in UploadInfo.getFileName(). Client-supplied filename metadata (e.g. Upload-Metadata: filename <base64>) was returned verbatim without stripping directory paths (Unix / and Windows \), directory traversal sequences (..), or null bytes (\0). Furthermore, calling getFileName() on an UploadInfo instance lacking an ID threw a NullPointerException.

Impact

Applications consuming UploadInfo.getFileName() (e.g. in UploadCompletionListener callbacks or custom controller endpoints) to write or save uploaded files to a target directory (such as new File(targetDir, info.getFileName()) or targetDir.resolve(info.getFileName())) are vulnerable to arbitrary file write / path traversal outside the intended directory.

Fix

  • Introduced Utils.sanitizeFileName(String fileName, UploadId uploadId) to strip Unix and Windows directory segments, directory traversal sequences (..), and null bytes (\0), safely falling back to the upload ID (or "download" if null).
  • Updated UploadInfo.getFileName() to return the sanitized filename.
  • Refactored DownloadGetRequestHandler to share Utils.sanitizeFileName.
  • Added unit tests in UploadInfoTest and UtilsTest covering directory traversal patterns, traversal-only strings, null bytes, and null fallbacks.

Verification

  • Formatting: verified with mvn -P codestyle com.spotify.fmt:fmt-maven-plugin:format -q (100% compliant).
  • Tests: all unit tests passed (mvn test -Dtest="*Test" -q).
  • Code Coverage: consolidated coverage across all modified files exceeds 90% (python3 scripts/check-coverage.py --per-file-limit 90).

@tomdesair
tomdesair merged commit f9f02cf into bugfix/cloud-robustness-security-performance Nov 15, 2026
2 checks passed
tomdesair added a commit that referenced this pull request Nov 15, 2026
…152)

* fix: resolve distributed cloud performance, security, and robustness concerns

- Fix POST creation-with-upload lock acquisition and watchdog leak: ensure
  distributed lease lock is acquired for newly created uploadId and released
  cleanly on stream completion or abortion across Tus and RUFH.
- Enforce stream safety and rollback integrity: rollback uncommitted bytes
  on client stream interruptions and reset tentative length for RUFH deferred
  length uploads.
- Prevent parent upload truncation on child error rollback in S3 and Azure
  Blob storage services.
- Increase S3 server-side compose HTTP timeouts to 60s for large uploads and
  preserve fallback behavior.
- Harden against HTTP request smuggling and DoS: enforce strict CRLF and chunk
  size validation in chunked transfer encoding stream and bound metadata length.
- Optimize pattern compilation using ConcurrentHashMap caching.
- Add preliminary request validation in getRawInterimResponse to prevent
  phantom upload creation on invalid requests.
- Add integration test for chunked streaming with trailing checksum verification
  across Disk, S3, and Azure backends.

* fix(security): prevent path traversal in Content-Disposition and add nosniff header in download extension

* fix: harden 2.0.0 concurrency, cache eviction, error handling, and docs

- Evict pre-lock ThreadLocal cache entries on lock acquisition in ThreadLocalCachedStorageAndLockingService
- Harden protocol handlers, validators, stream/header parsing, and Disk/S3/Azure storage, locking, and deduplication
- Add unit tests covering new edge cases and error paths
- Clean up CHANGELOG.md for 2.0.0 and update AGENTS.md and storage/architecture docs

* Harden containerized CI integration tests, extract InMemoryAzureHttpResponse, and improve coverage

* fix(security): sanitize UploadInfo.getFileName() to prevent path traversal (#153)
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