Skip to content

test: reconcile env-var security test with callable traversal hardening - #12430

Merged
julian-risch merged 1 commit into
mainfrom
fix/serialization-security-test-after-traversal-hardening
Aug 21, 2026
Merged

test: reconcile env-var security test with callable traversal hardening#12430
julian-risch merged 1 commit into
mainfrom
fix/serialization-security-test-after-traversal-hardening

Conversation

@julian-risch

@julian-risch julian-risch commented Aug 21, 2026

Copy link
Copy Markdown
Member

Related Issues

main is red on all three OS runners with one failing test:

FAILED test/core/test_serialization_security.py::TestUnsafeDeserializationEnvVar::
       test_env_write_reachable_from_serialized_data_cannot_disable_safety
  DeserializationError: Refusing to deserialize a class from module 'os'
= 1 failed, 6276 passed, 8 skipped, 323 deselected =

Proposed Changes:

Split the unit test for deserialization security so each defense layer is covered on its own

How did you test it?

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes. — n/a, no issue; the failing CI run is linked above
  • I have added unit tests and updated the docstrings. — test-only PR; both tests carry docstrings explaining which layer they guard
  • I've used one of the conventional commit types for my PR title: test:, no breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines. — n/a, test-only change, labelled ignore-for-release-notes
  • I have run pre-commit hooks and fixed any issue.

#12397 landed a regression test that resolves `os.environ.update` through an
allowlisted module's scope-level `environ` binding to prove that an env write
during a load cannot flip the frozen unsafe-mode snapshot. #12416 landed the
per-hop resolved-module check in `deserialize_callable`, which refuses that
`environ` hop outright because the object belongs to the un-allowlisted `os`.

Both were green on their own bases and merged without a re-run, so main now
fails: the test's premise ("a serialized handle can resolve that mutator in
safe mode") is no longer true.

Split the test in two so each defense layer is covered independently:

- the gadget is no longer resolvable at all (asserts the #12416 rejection,
  matching on the `os` module in the error);
- the frozen snapshot still cannot be flipped by an env write, granted the
  write by other means so this keeps testing only that property.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@julian-risch julian-risch added the ignore-for-release-notes PRs with this flag won't be included in the release notes. label Aug 21, 2026
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Aug 21, 2026 1:41pm

Request Review

@julian-risch
julian-risch marked this pull request as ready for review August 21, 2026 13:42
@julian-risch
julian-risch requested a review from a team as a code owner August 21, 2026 13:42
@julian-risch
julian-risch requested review from davidsbatista and sjrl and removed request for a team and sjrl August 21, 2026 13:42
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/converters
  output_adapter.py
  haystack/components/routers
  conditional_router.py
  haystack/core
  serialization_security.py
Project Total  

This report was generated by python-coverage-comment-action

@julian-risch julian-risch added this to the 3.1 milestone Aug 21, 2026
@julian-risch
julian-risch enabled auto-merge (squash) August 21, 2026 13:48

@davidsbatista davidsbatista 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.

looks good

@julian-risch
julian-risch disabled auto-merge August 21, 2026 13:50
@julian-risch
julian-risch merged commit c7cb46c into main Aug 21, 2026
29 checks passed
@julian-risch
julian-risch deleted the fix/serialization-security-test-after-traversal-hardening branch August 21, 2026 13:50
davidsbatista pushed a commit that referenced this pull request Aug 21, 2026
…ng (#12430)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release-notes PRs with this flag won't be included in the release notes. topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants