Repository navigation
Release v0.0.6: security hardening, bug fixes, packaging & CI modernization - #4
Merged
Merged
Conversation
…zation
Security:
- Block ALL attribute names starting with __ (was a hardcoded dunder list),
closing a sandbox-escape bypass where dunders were read through string
arguments, e.g. ().__getattribute__('__class__') with allow_attributes=True
- Always terminate the evaluation child on timeout; immediate_termination=False
previously leaked unkillable CPU-spinning processes (now deprecated)
- Remove dir() and id() from the default safe builtins
Bug fixes:
- Serialize eval results synchronously in the child via pickle; unpicklable
results (lambdas, generators, mappingproxy) now raise a clear RuntimeError
instead of a misleading EvaluationTimeoutError from the queue.empty() race
- encrypt() fails loudly on characters outside the mapping alphabet instead of
silently corrupting non-ASCII code; custom mapping values validated to be
exactly 64 characters
- decrypt() validates Base64 input (validate=True); whitespace-tolerant
- Non-positive timeout values rejected with ValueError
- run() executes decrypted code with __name__='__main__' in an isolated namespace
- Explicit UTF-8 for all file I/O; exception chaining; original exception types
propagate from child processes; anchored '# <base64>' extraction regex
Packaging/CI:
- New PEP 621 pyproject.toml (SPDX MIT) - pip install/python -m build now work
from a fresh checkout (was {{VERSION_PLACEHOLDER}}, an invalid version)
- Publish workflow fixed (deprecated set-output, @master actions), added
tag<->version consistency check; added test.yml (py3.8-3.12, linux/win/mac)
Docs/tests:
- CVE-2026-133467 referenced in changelog (was 'CVE pending')
- README, supported Python versions (>=3.8), v0.0.6 changelog
- New SECURITY_AUDIT.md with full findings and remediation notes
- 73 tests passing; test_security_error_on_unsafe_function can no longer pass silently
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…release flow Encryption (breaking change, documented): - encrypt() now uses Fernet (AES-128-CBC + HMAC-SHA256) with a 256-bit key; any Unicode source round-trips losslessly (plaintext is UTF-8) - New generate_key() helper; keys resolve via key= > CODESAFE_KEY env > built-in default (public, obfuscation-grade, documented) - Files written by encrypt_to_file() are self-describing: # codesafe:v2:<token> - Legacy pre-0.0.6 Base64 Caesar payloads remain fully decryptable/runnable via decrypt()/decrypt_to_file()/run(); legacy mapping still honored there - encrypt() no longer accepts the Caesar mapping parameter (TypeError) safe_eval: - Restricted imports parameter removed (redundant with the blanket import ban) - Results are serialized with cloudpickle: lambdas and dynamically created classes can now be returned; generators/modules still raise a clear RuntimeError (instead of the old misleading EvaluationTimeoutError) CI/release: - Tests run on 3.8/3.9 via ubuntu-22.04 (not available on ubuntu-latest/24.04, which is why those jobs failed at setup); deps installed directly - Publish workflow uses PyPI Trusted Publishing (OIDC, id-token: write); no stored API tokens; distributions carry PEP 740 provenance attestations - README gains a provenance badge linked to the PyPI security tab Docs: - New SECURITY.md (private reporting instructions, supported versions, published advisories) - SECURITY_AUDIT.md dropped; its content now lives in the README (Security Advisory + Security Limitations & Notes sections) - v0.0.5 changelog now carries a prominent warning about the second, known sandbox-escape issue (allow_attributes=True, fixed in 0.0.6) - _ = backwards-compatible positional legacy mapping for decrypt-time calls Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
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.
Summary
Audit + hardening release for CodeSafe. Fixes two sandbox/resource-safety bugs in
safe_eval(), a silent data-corruption bug inencrypt(), a broken package build, and a broken publish workflow. The previously "CVE pending" advisory is now referenced by its assigned ID: CVE-2026-133467.Security fixes
allow_attributes=True): all attribute names starting with__are now rejected, closing().__getattribute__('__class__')-style reads that defeated the old hardcoded dunder blocklist.immediate_termination=Falseno longer leaks an unkillable CPU-spinning process (parameter deprecated).dir()andid()from the default safe builtins.Bug fixes
mappingproxy) now raise a clearRuntimeErrorinstead of a misleadingEvaluationTimeoutError; results are serialized synchronously in the child, eliminating the unreliablequeue.empty()race.encrypt()fails loudly on characters outside its supported alphabet — previously any non-ASCII code was silently corrupted and unrecoverable. Custom mapping values are validated (exactly 64 chars).decrypt()validates Base64 input; whitespace-tolerant; clear errors.timeout→ValueError;run()executes with__name__ == '__main__'in an isolated namespace; explicit UTF-8 everywhere; exception chaining; original exception types propagate from child processes.Packaging & CI
pyproject.toml(SPDXMIT) —pip install ./python -m buildnow work from a fresh checkout (previously the{{VERSION_PLACEHOLDER}}version made them fail).set-outputremoved, actions updated, tag↔version consistency check added; publish usespypa/gh-action-pypi-publish@release/v1.test.ymlCI: both test suites on Python 3.8–3.12 (Linux) and 3.12 (Windows/macOS) on every push/PR.Docs & tests
SECURITY_AUDIT.mdwith full findings, remediations, and residual-risk recommendations.TestHardeningRegressionsuite + functional tests;test_security_error_on_unsafe_functioncan no longer pass silently.Verification
python -m unittest test.py test_poc_vulnerability.py→ 73 tests, all passingpython -m build→ clean sdist + wheel (builds from scratch);pip installfrom both verified🤖 Generated with Arena Agent Mode