Skip to content

fix: harden blob store against path injection, partial writes, and temp file leakage (#545) - #557

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/545-security-blob-sandbox
Apr 28, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/545-security-blob-sandbox

Conversation

@Sinity

@Sinity Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

Five security and data-integrity fixes to blob store and path sanitization.

Problem

  • blob_path() had no validation on hash_hex, allowing path injection via ../
  • os.write() partial writes could silently corrupt blobs
  • Crash-left temp files (*.blob.*) were yielded as valid blobs
  • Heartbeat callback exceptions aborted blob writes
  • sanitize_path() passed absolute paths like /etc/passwd through unmodified

Solution

  • Validate hash_hex against ^[0-9a-f]+$ regex
  • Retry partial os.write() in a loop
  • Filter temp files from iter_all()
  • Suppress heartbeat exceptions with contextlib.suppress
  • Block absolute paths in sanitize_path(), returning _blocked_<hash>

Closes #545

🤖 Generated with Claude Code

…mp file leakage

Five security/data-integrity fixes:

1. blob_store.py: validate hash_hex is lowercase hex before constructing
   filesystem path — prevents path injection via ../ or / in malformed
   raw_id values.

2. blob_store.py: replace bare os.write() with _write_all() that retries
   partial writes in a loop — prevents silent blob corruption on large
   chunks.

3. blob_store.py: filter .blob.* temp files in iter_all() — prevents
   crash-left temp files from being yielded as valid blobs.

4. blob_store.py: wrap heartbeat() calls in suppress() so a callback
   failure does not abort the entire blob write.

5. lib/security.py: reject absolute paths in sanitize_path() — prevents
   sandbox escape via attacker-controlled absolute paths like /etc/passwd
   when no allowlist for safe directories is configured.

Also moves `import hashlib` to module level in security.py (was
function-local) and updates two test files for the new absolute-path
behavior.

Closes #545

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 56 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4328cb43-c3b8-4f9f-8e2c-df3dadafe0e5

📥 Commits

Reviewing files that changed from the base of the PR and between f6b67c1 and b6b8e3f.

📒 Files selected for processing (4)
  • polylogue/lib/security.py
  • polylogue/storage/blob_store.py
  • tests/unit/security/test_attachment_security.py
  • tests/unit/security/test_path_sanitization.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/545-security-blob-sandbox

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 59 minutes and 56 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit dd2fa45 into master Apr 28, 2026
5 of 11 checks passed
@Sinity
Sinity deleted the feature/fix/545-security-blob-sandbox branch April 28, 2026 08:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b6b8e3fb47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/lib/security.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

Sinity added a commit that referenced this pull request May 7, 2026
…mp file leakage (#557)

## Summary
Five security and data-integrity fixes to blob store and path
sanitization.

## Problem
- `blob_path()` had no validation on `hash_hex`, allowing path injection
via `../`
- `os.write()` partial writes could silently corrupt blobs
- Crash-left temp files (`*.blob.*`) were yielded as valid blobs
- Heartbeat callback exceptions aborted blob writes
- `sanitize_path()` passed absolute paths like `/etc/passwd` through
unmodified

## Solution
- Validate hash_hex against `^[0-9a-f]+$` regex
- Retry partial `os.write()` in a loop
- Filter temp files from `iter_all()`
- Suppress heartbeat exceptions with `contextlib.suppress`
- Block absolute paths in `sanitize_path()`, returning `_blocked_<hash>`

Closes #545

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

Only the rows listed above are dispositioned. Held findings remain open.

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.

fix(security): blob_store path injection, sandbox escape, and data integrity

2 participants