Skip to content

security: harden release artifact validation - #495

Merged
codeforester merged 3 commits into
mainfrom
security/486-20261028-artifact-content-checks
Oct 28, 2026
Merged

codeforester merged 3 commits into
mainfrom
security/486-20261028-artifact-content-checks

Conversation

@codeforester

Copy link
Copy Markdown
Contributor

Summary

  • reject duplicate, traversal, startup-hook, symlink, executable, and native-library archive members
  • compare packaged base_cli files byte-for-byte with the reviewed source tree
  • add malicious archive fixtures for duplicate members, traversal, and startup hooks
  • preserve legitimate executable Python files under scripts/ in sdists

Security rationale

The release validator now fails closed before installation. It checks both wheel and sdist content and does not import or execute the artifact while validating it.

Validation

  • UV_CACHE_DIR=/private/tmp/base-cli-uv-cache uv run --extra dev pytest -q tests/test_validate_package_artifact.py
  • UV_CACHE_DIR=/private/tmp/base-cli-uv-cache uv run --extra dev python -m build --wheel --sdist
  • UV_CACHE_DIR=/private/tmp/base-cli-uv-cache uv run --extra dev python scripts/validate_package_artifact.py dist
  • Ruff and git diff --check pass

Relates to #486.

@codeforester
codeforester force-pushed the security/486-20261028-artifact-content-checks branch from c8541ec to 3660261 Compare October 27, 2026 18:53
Comment thread scripts/validate_package_artifact.py
Comment thread scripts/validate_package_artifact.py
Comment thread scripts/validate_package_artifact.py Outdated
Comment thread scripts/validate_package_artifact.py
@codeforester

Copy link
Copy Markdown
Contributor Author

Implemented the review fixes in commit 703267a2.

  • Wheel directory entries are skipped before executable-bit validation, so legitimate directory modes do not fail artifact validation.
  • Wheel symbolic links are rejected explicitly using the Unix file-type bits, matching the sdist hard-link/symlink policy.
  • Added regression tests for both behaviors.

@codeforester

Copy link
Copy Markdown
Contributor Author

Addressed the remaining lint and maintainability feedback in commit dc117eb6.

  • Replaced the UTF-8 string .encode() with a bytes literal (UP012).
  • Removed the dead expected_package_files() traversal and made expected_package_hashes() the single source of truth.
  • Derived the sdist package prefixes from IMPORT_NAME instead of duplicating base_cli literals.

The directory-entry and symlink regression tests remain in place.

@codeforester
codeforester merged commit 10c29d5 into main Oct 28, 2026
118 checks passed
@codeforester
codeforester deleted the security/486-20261028-artifact-content-checks branch October 28, 2026 15:01
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