PR-5: Security trio — archive hardening, license-secret hygiene, bind warning + client token sync - #31
Merged
Merged
Conversation
Validate every zip/tar member (OS-independent traversal, link and device rejection) via shared core/archive_safety; ingest and library install use it. _install_package stages, backups, and swaps so a failed replacement restores the working install. Install ValueError still aborts sync.
…docs Extract the existing explicit/env/legacy/default precedence into _resolve_license_secret; no behavior change. Docstrings state the repo default is publicly forgeable demo-only, commercial builds must inject MATERIALSCOPE_LICENSE_SECRET, rotation requires re-issuance, and real distributable licensing wants asymmetric signing (deferred).
…nt token Explicit --token/api_token stays the sole server-auth source and now overwrites a stale MATERIALSCOPE_API_TOKEN so the co-located Dash UI keeps working; client resolves the token per call. No enforcement; /health stays open.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR-5 — Security trio (Phase 0)
Three independent, individually revertable commits. No science changes, no enforcement changes.
Track A — archive extraction hardening + failure-atomic install
core/archive_safety.py: OS-independent lexical validation (POSIX absolutes, drive-qualified/rooted/UNC Windows paths,..across both separators, NULs) + resolved containment check; ZIP symlink rejection; TAR allow-list of regular files/directories only. Manual checks instead oftarfile filter="data"(3.11 floor).tools/library_ingest/common.pyandcore/reference_library._install_packageuse it._install_packagerewritten as validate→stage→backup→promote→cleanup: a hostile/corrupt replacement raises before the working install is touched, and a failed promotion restores the previous install from backup. Install-levelValueErrorstill abortssync(), exactly like hash mismatches.archive_pathbytes are written only after the new payload passes validation. Not claimed: crash-atomicity across process kill, or archive-bytes/extracted-tree transactional coupling.Track B — license-secret resolution hygiene (no crypto claims)
_resolve_license_secret()with byte-identical behavior; no signature or caller changes.MATERIALSCOPE_LICENSE_SECRETexternally; changing the secret invalidates existing HMAC-signed licenses (re-issue required). Real distributable licensing should migrate to asymmetric signing (Ed25519/RSA, public verification key only) — explicitly deferred, roadmap PR-7 owns docs truth.Track C — bind warning + bundled-client token sync (no enforcement)
non_loopback_bind_warning()(ipaddress.is_loopback+localhostfallback, fail-safe on empty host) printed at startup by bothdash_app.serverandbackend.main./healthstays unauthenticated (Docker HEALTHCHECK depends on it).server --token Xfeeds backend auth while the co-located Dash client read its token once at import. Now the explicit server token overwrites a staleMATERIALSCOPE_API_TOKEN(explicit wins), and the client resolves the token per call. Server auth is still controlled only by--token/api_token.Verification (local)
ruff check .→ cleanpython -m pytest tests/ -q→ 1221 passed / 10 skipped (baseline 1184/10 at Replace legacy ASGI-to-WSGI bridge with native Dash FastAPI backend #28; delta is exactly the 37 new tests, zero regressions)tests/test_archive_extraction_safety.py(23),tests/test_container_bind_warning.py(7); extendedtest_license_manager.py,test_dash_fastapi_backend.py(token-wins, import-order independence, open contract,/health).Commits
feat: harden archive extraction with rollback-capable library installchore: centralize license-secret resolution with honest forgeability docsfeat: warn on unauthenticated non-loopback bind and sync bundled client token