Chiosa
AI Security & Safety

AegisAsync traces Python async behavior to flag risks

AegisAsync: Symbolic Async-Event Simulation for Risks in Python Asynchronous Programs · arXiv:2610.18831

3 min
Updated

In plain words

Python async programs can have risks that depend on what happens to the same task later, or how execution continues after an error or cancellation.

AegisAsync is a static checker that follows compiled program instructions, connects related async events, and checks selected execution paths for six kinds of risk.

On a constructed test collection, it found all 180 labeled risks and made no false-positive reports on safe controls across five tested Python versions. This result applies to those test cases.

The research

Can a checker recognize an async risk when it depends on what happens to the same task later, or on how a program continues after cancellation? Those clues can be spread across operations and execution paths, so identifying a risky API call alone may not establish that the risk occurs.

AegisAsync links bytecode instructions, async events and symbolic objects, then checks bounded execution paths for six kinds of Python async risk.

On AsyncBench, a constructed collection of labeled async risks and safe programs, AegisAsync detects all 180 labeled risks and reports none on 14 safe controls across five CPython versions. It also detects all 90 risks in the three families shared with flake8-async, which detects 40.

In a stratified sample of PyPI artifacts, reviewers confirm 457 of 910 AegisAsync candidate records as unique bugs. Executable reproductions connect source-confirmed findings to runtime behavior across all six risk families.

The test results cover constructed cases, while package findings come from a stratified sample and a particular review protocol. AegisAsync’s bounded paths and object analysis can miss behaviors or produce false reports.

What the evidence shows

  • Risks depend on connected events

    AegisAsync is a bytecode-based static analysis framework for finding security and robustness risks in Python asynchronous programs. The challenge is that a risk may depend on event order, the identity and lifetime of an object, or what happens after an exception or cancellation.

    A checker that recognizes individual API calls may not connect the operations that establish such a risk.

  • Link operations along paths

    AegisAsync builds an Async Event Transition Graph that links program instructions and possible execution transfers with async events and symbolic objects. It then follows selected paths, tracks event order and abstract task states, and explores cancellation continuations from await suspensions.

    Six detectors inspect the resulting traces and states for different risk conditions, reporting candidates with supporting witnesses.

  • Test evidence and detection

    AsyncBench is a constructed test collection with labeled async risks and safe controls. It measures whether the analysis preserves each risk’s required source locations, event relationships, and witness facts, and whether it flags labeled risks.

    Across 180 labeled risks and five CPython versions, AegisAsync passes all four evidence checks for every risk-version instance and detects all labeled risks without reports on the 14 safe controls.

  • Compare on shared risk families

    On the 90 AsyncBench risks in the three families shared with flake8-async, AegisAsync detects all 90, while flake8-async detects 40. This comparison holds the labeled instances constant and concerns only those shared families; it does not compare all six AegisAsync risk families.

    The authors also assess real packages through source review, which tests whether reported candidates correspond to defects supported by source and an execution path.

  • Review real package candidates

    The package study draws a stratified sample of 2,500 artifacts from 76,453 eligible PyPI artifacts. Reviewers confirm 457 of 910 deduplicated AegisAsync candidate records, representing 457 unique bugs.

    For sampled flake8-async judgments in the three shared families, reviewers confirm 70 of 2,187 judgments, representing 33 unique sites; AegisAsync reports all 33. The authors further report executable reproductions of findings across all six risk families.

Deep

Next paperNOMOS makes written policies safer for tool-using agents