Skip to content

Python: [Bug]: Checkpoint decoder accepts malformed Base64 pickle payloads #8257

Closed

Description

@fzfzzfzzzfzzzz

Description

The checkpoint pickle decoder calls base64.b64decode() without strict validation. Python's default decoder discards non-alphabet characters, so a malformed checkpoint envelope can be accepted and decoded successfully even though the public decoder documentation says malformed base64 data raises WorkflowCheckpointException.

Expected behavior: malformed base64 checkpoint payloads should fail deterministically with WorkflowCheckpointException rather than being normalized silently.

I intend to submit a focused fix using strict base64 validation and regression tests for invalid characters while preserving valid payload behavior.

Code Sample

from agent_framework._workflows._checkpoint_encoding import (
    decode_checkpoint_value,
    encode_checkpoint_value,
)

encoded = encode_checkpoint_value((1, 2, 3))
encoded["__pickled__"] += "!!!!"

print(decode_checkpoint_value(encoded))

Actual output:

(1, 2, 3)

Expected: WorkflowCheckpointException indicating malformed base64 data.

Error Messages / Stack Traces

No exception is currently raised.

Package Versions

agent-framework-core: source checkout of main at d7823b2

Python Version

Python 3.11.9

Additional Context

base64.b64decode(encoded.encode("ascii"), validate=True) provides the intended strict validation and is compatible with payloads produced by the existing base64.b64encode(...).decode("ascii") encoder.

AI assistance was used to audit the decoder and prepare the reproduction; the behavior was verified against the referenced source checkout.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 10, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Sep 10, 2026
  3. github-actions commented on Sep 10, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    The bug occurs in python/packages/core/agent_framework/_workflows/_checkpoint_encoding.py::_base64_to_unpickle at line 406 when a pickle envelope’s Base64 payload contains non-alphabet characters. Minimal repro: encode (1, 2, 3), append !!!! to encoded["__pickled__"], and assert that decode_checkpoint_value(encoded) raises WorkflowCheckpointException; it currently returns the tuple.

    • Failing test: python/packages/core/tests/workflow/test_checkpoint_decode.py::test_decode_raises_on_malformed_base64_pickle_payload
    • Files examined: python/packages/core/agent_framework/_workflows/_checkpoint_encoding.py, python/packages/core/agent_framework/_workflows/_checkpoint.py, python/packages/core/tests/workflow/test_checkpoint_decode.py, python/packages/core/pyproject.toml
    • Tests run: python/packages/core/tests/workflow/test_checkpoint_decode.py, python/packages/core/tests/workflow/test_checkpoint_decode.py::test_decode_raises_on_malformed_base64_pickle_payload
    • Reported version: source checkout of main at d7823b2
    • Current version: 1.18.0
  4. added
    workflowsUsage: [Issues, PRs], Target: Workflows
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowworkflowsUsage: [Issues, PRs], Target: Workflows

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions