Anti-AIClone

Log date · Fri

Does CPyGraph show Python bytecode can be analyzed?

Yes. In our .pyc comparison, optimization removed an assertion but left pricing constants and branches visible.

The answer: bytecode still exposes structure

Yes. Shipping only .pyc does not make program logic confidential. We compiled the same quoting function with CPython 3.8.20: the normal version has 24 instructions and the optimized version has 16. Optimization removed an assertion, but both retained the threshold 100, multiplier 80 and a branch.

That observation connects to CPyGraph: bytecode can support structured static analysis, but analysis across versions must account for changing semantics. [1] Our small standard-library experiment illustrates the issue; it is neither a test of CPyGraph nor a replication of its results, and it does not evaluate commercial hardening or custom loaders.

Our comparison
QuestionFinding
Did optimization hide the rule?No; 100, 80 and the branch remain visible.
What happened to the assertion?It is absent in the optimized version.
Is this the paper’s benchmark?No; this inspects our own function.

What the paper actually measured

Baihong Chen and Wen Li submitted CPyGraph v1 (arXiv 2609.25083, cs.CR) at 21:25 UTC on 2026-09-18. Their C++ framework uses version-specific adapters to present CPython 3.10 through 3.14 bytecode semantics through a shared interface while retaining code-object identities and native offsets. [1]

The paper computes an operand-stack-aware Andersen-style points-to analysis and a call graph together to a fixed point, then builds exception-aware control-flow graphs, control-dependence graphs and interprocedural data-dependence graphs. Its goal is security-oriented static analysis; that is different from recovering the original source text.

The authors report 201 package-level programs and 1,733 candidates in PYGBench. The default CPython 3.10 configuration reached 91.40% candidate precision and 100% recall; 1,328 of 1,334 version-invariant queries agreed across 3.10–3.14. [1] These are benchmark results, not a guarantee for every application or protection scheme.

Compare two compiled variants

We wrote a fictional quote function: quantities of at least 100 use a multiplier of 80, otherwise the multiplier is 100. An assertion rejects negative quantities; DEMO-TIER is only a label, not a credential. We used py_compile with optimize=0 and optimize=1 to write two .pyc files. [3]

The complete function in our sample.
def quote(units):
    assert units >= 0, "units must be nonnegative"
    if units >= 100:
        return "DEMO-TIER", units * 80
    return "DEMO-TIER", units * 100

We then read the compiled code object with SourcelessFileLoader.get_code and listed its instructions with dis.get_instructions; the inspection did not execute the sample module. [2][4] These two lines from the full transcript show the function constants before and after optimization.

Normal and optimized constants, respectively; two lines selected for comparison.
constants: (None, 0, 'units must be nonnegative', 100, 'DEMO-TIER', 80)
constants: (None, 100, 'DEMO-TIER', 80)

The normal version contains AssertionError and RAISE_VARARGS; the optimized one does not. Both contain comparison, conditional jump and multiplication instructions. The numbers alone do not explain the whole business meaning, but together with the branch and operations they point an auditor toward this pricing rule. Do not use assert for input validation that must always run.

Version differences and inspection limits

The Python documentation says CPython bytecode is an implementation detail: instructions can change between versions, and dis is not guaranteed to work across releases or virtual machines. [2] Record the interpreter that generated the .pyc and inspect it with a matching interpreter; do not treat the 3.8 instruction names or offsets here as a stable format for other versions.

Source-free distribution also has a compatibility cost. The SourcelessFileLoader documentation warns that bytecode-only modules may not work on other Python implementations or newer versions that change the bytecode format. [4] Static inspection can reveal retained information; failing to find a string does not establish that it is absent from all resources, dependencies or runtime paths.

Recommendations by asset

These are design recommendations, not protection effects measured by our comparison. Separate public information, user credentials and server secrets first, then decide which decisions genuinely must run offline.

Recommendations by asset
CaseRecommendation
Shared privileged keyKeep it on a controlled server; rotate an exposed key and verify revocation.
Sensitive pricing or abuse ruleRun it on the server where feasible and control access.
Offline licenceVerify a public-key signature on the client; keep the private key at the issuer.
Logic that must run offlineAccept the analysis risk explicitly; measure protection and compatibility on the target build.

Moving decisions server-side requires a plan for latency, connectivity and failures; offline licensing needs expiry, device migration and revocation policies. Moving a rule into native code does not make it confidential either, so assess costs and results on each supported platform.

Check your own release artifact

Inventory .pyc files, stray source, configuration and resources in a release artifact you own or are authorized to inspect. Use the command below to list your own already-unpacked directory.

Replace the path with your own already-unpacked directory.
find path/to/your-unpacked-release -type f

For a known module of your own, use SourcelessFileLoader.get_code to select the right code object and dis.get_instructions to list its instructions. In our sample, we selected only a function named quote; real code may contain nested functions, dynamic calls and other resources. Record the Python version, build options and findings, then repeat after interpreter or packaging changes. Keep real tokens and sensitive output out of public logs.

Your checklist

  • Record the release CPython version and optimization options.
  • Inventory bytecode, source, configuration and resources.
  • Inspect constants, branches and required input validation in important functions.
  • Move shared privileged secrets server-side and rotate exposed values.
  • Repeat compatibility and artifact checks after interpreter or packaging changes.

Primary sources

All sources and reproduction status ↗