Skip to content

fix(sandbox): widen boxlite/aio_sandbox tenant hash and verify identity on reclaim - #4171

Merged
WillemJiang merged 2 commits into
bytedance:mainfrom
DaoyuanLi2816:fix/sandbox-tenant-id-truncation
Jul 26, 2026
Merged

fix(sandbox): widen boxlite/aio_sandbox tenant hash and verify identity on reclaim#4171
WillemJiang merged 2 commits into
bytedance:mainfrom
DaoyuanLi2816:fix/sandbox-tenant-id-truncation

Conversation

@DaoyuanLi2816

@DaoyuanLi2816 DaoyuanLi2816 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • widen BoxLite and AIO deterministic tenant IDs from 8 to 16 hex characters
  • track the full (user_id, thread_id) identity for active and warm entries
  • fail closed on any identity mismatch without evicting the rightful tenant's warm sandbox
  • guard reclaim and health-check races against same-ID entry replacement
  • reuse an already-registered BoxLite instance for a late same-tenant race while closing the duplicate instance

Older 8-character containers are not reused after rollout and remain eligible for normal orphan cleanup. Startup-adopted warm entries have unknown identity until their first successful reclaim; subsequent reclaims enforce the recorded identity.

Tests

  • complete BoxLite and AIO provider modules (71 passed)
  • targeted same-tenant and cross-tenant collision regressions
  • Ruff check and format check on the changed files

@github-actions github-actions Bot added area:docs Documentation and Markdown only risk:medium Medium risk: regular code changes size/L PR changes 300-700 lines labels Jul 14, 2026

@willem-bd willem-bd 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.

Reviewed against PR head (1bf7d77) and the current codebase; ran both suites against the PR's code (73 passed) and probed the residual-collision path empirically (probe since removed, working tree verified clean).

Verdict: approve. The 64-bit widening closes the real production bug (32-bit ~77k-pair birthday bound), and the identity check is a sound reclaim-path backstop that correctly handles the release/acquire inter-check race (re-checked immediately before promotion). _thread_key ordering is consistent between acquire and release; reset() (Boxlite) correctly preserves identity; AIO has no reset() so no parity gap.

The substantive inline comment (on both providers) documents a residual persistent-collision leak that is production-moot (needs a real 64-bit collision) but currently untested - the main actionable is extending the forced-collision test through A.re-acquire-while-B-active so the boundary is documented and regression-safe. The rest are minor nits.

  • area:docs label looks wrong - this is a security code fix (2 provider files + 2 test files + doc), not docs-only. Same mislabel seen on PR #4025; should be the sandbox/security area.

Comment thread backend/packages/harness/deerflow/community/boxlite/provider.py
Comment thread backend/packages/harness/deerflow/community/boxlite/provider.py Outdated
Comment thread backend/tests/test_boxlite_provider.py Outdated
Comment thread backend/packages/harness/deerflow/community/boxlite/provider.py Outdated
@WillemJiang WillemJiang added the reviewing A maintainer is reviewing this PR label Jul 15, 2026
@WillemJiang WillemJiang added this to the 2.1.0 milestone Jul 15, 2026
Comment thread backend/packages/harness/deerflow/community/boxlite/provider.py Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 06:17
@DaoyuanLi2816
DaoyuanLi2816 force-pushed the fix/sandbox-tenant-id-truncation branch from 764fe3f to 32a4106 Compare July 24, 2026 06:17
@github-actions github-actions Bot removed the area:docs Documentation and Markdown only label Jul 24, 2026

Copilot AI 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.

Pull request overview

This PR hardens the BoxLite and AIO sandbox warm-pool reclaim logic against deterministic-ID collisions by widening the truncated SHA-256 tenant hash (8 → 16 hex chars) and introducing explicit identity tracking/checks so a warm entry can’t be silently reclaimed by the wrong (user_id, thread_id).

Changes:

  • Widen deterministic sandbox IDs in both BoxliteProvider and AioSandboxProvider from 32-bit to 64-bit truncation.
  • Add per-sandbox identity tracking for both active and warm-pool entries, and enforce identity checks during reclaim/promote.
  • Expand unit tests (and a few helper provider constructors in tests) to cover the widened-ID behavior and identity/collision handling.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
backend/packages/harness/deerflow/community/boxlite/provider.py Widen BoxLite deterministic IDs; add warm/active identity tracking and collision detection during warm reclaim and creation.
backend/packages/harness/deerflow/community/aio_sandbox/aio_sandbox_provider.py Widen AIO deterministic IDs; add warm/active identity tracking and collision checks/handling across reclaim/discover/create paths.
backend/tests/test_boxlite_provider.py Update existing warm-pool tests for new reclaim signature and add tenant-isolation/collision coverage.
backend/tests/test_aio_sandbox_provider.py Seed identity maps in test providers and add tenant-isolation/collision coverage.
backend/tests/test_sandbox_orphan_reconciliation.py Initialize new identity maps in reconciliation test provider setup.
backend/tests/blocking_io/test_sandbox_release.py Initialize new AIO identity maps in blocking-IO release test provider setup.
backend/tests/blocking_io/test_aio_sandbox_get.py Initialize new AIO identity maps in blocking-IO get test provider setup.

Comment thread backend/packages/harness/deerflow/community/boxlite/provider.py Outdated
Comment thread backend/packages/harness/deerflow/community/aio_sandbox/aio_sandbox_provider.py Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 06:59
@DaoyuanLi2816
DaoyuanLi2816 force-pushed the fix/sandbox-tenant-id-truncation branch from 32a4106 to 12fbd25 Compare July 24, 2026 06:59

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread backend/packages/harness/deerflow/community/boxlite/provider.py
Copilot AI review requested due to automatic review settings July 24, 2026 22:04

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@WillemJiang
WillemJiang merged commit 5d07399 into bytedance:main Jul 26, 2026
18 checks passed
yangjl pushed a commit to yangjl/deer-greenagent that referenced this pull request Jul 26, 2026
…ty on reclaim (bytedance#4171)

* fix(sandbox): prevent truncated tenant ID reuse

* fix(sandbox): handle late same-tenant box registration
marvin9551 pushed a commit to marvin9551/deer-flow that referenced this pull request Aug 21, 2026
…ty on reclaim (bytedance#4171)

* fix(sandbox): prevent truncated tenant ID reuse

* fix(sandbox): handle late same-tenant box registration
jihtsan pushed a commit to jihtsan/dnx-deer-flow that referenced this pull request Aug 29, 2026
…ty on reclaim (bytedance#4171)

* fix(sandbox): prevent truncated tenant ID reuse

* fix(sandbox): handle late same-tenant box registration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewing A maintainer is reviewing this PR risk:medium Medium risk: regular code changes size/L PR changes 300-700 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants