Skip to content

fix(uploads): reject dot-segment storage keys before authorization and Azure Blob - #10314

Merged
waleedlatif1 merged 4 commits into
stagingfrom
fix/storage-key-traversal
Nov 22, 2026
Merged

waleedlatif1 merged 4 commits into
stagingfrom
fix/storage-key-traversal

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • tryInferContextFromKey returns null for any key with a ./.. segment, so prefix-based public checks (serve route, verifyFileAccess, key classifiers) can't be satisfied by a key that escapes its prefix
  • verifyFileAccess denies dot-segment keys up front
  • Every Azure block blob client is built through one guard that refuses them — the Blob SDK collapses dot segments when it builds the request URL, so og-images/../workspace/... addressed a different blob (or a sibling container). S3/GCS keep keys literal; local storage already threw in sanitizeFileKey, which now shares the same hasDotSegment helper

Type of Change

  • Bug fix

Testing

  • Reproduced the collapse against the installed @azure/storage-blob@12.34.0
  • New regression tests in authorization.test.ts, blob/client.test.ts, context-prefix.test.ts; each goes red with its guard reverted
  • authorization, blob/client, context-prefix, file, file.server, serve route suites: 123 passing
  • biome; type-check and audits via CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 22, 2026 11:04pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge.

Summary

Rejects dot-segment storage keys before file access checks, context classification, and Azure Blob calls.

  • Dot-segment keys no longer pass file checks or delete requests.
  • Azure Blob rejects dot-segment keys before building blob clients.

Reviews (4) · Last reviewed commit: "test(files): pass a route context in the..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/uploads/utils/file.ts Resolved
Comment thread apps/sim/lib/uploads/utils/file.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/uploads/utils/file.ts Resolved
…d Azure Blob

A caller-authored serve URL could decode to a key like og-images/../workspace/<id>/<file>.
Prefix-based checks classified it as a public context and skipped authorization, and the
Azure Blob SDK collapses dot segments when it builds the request URL, so the read landed on
another workspace's blob or a sibling container.

- tryInferContextFromKey answers null for a key with a . or .. segment, so no prefix check
  (serve route, verifyFileAccess, classifiers) trusts an escaped prefix
- verifyFileAccess denies such keys up front
- every Azure block blob client is built through one guard that refuses them
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 683064b into staging Nov 22, 2026
84 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/storage-key-traversal branch November 23, 2026 00:04

This branch was previously deployed

1 inactive deployment
Preview — 1696abb9 Deployed Nov 22, 2026 by vercel[bot]
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