Skip to content

Security: safely parse untrusted symbolic gain expressions - #4

Merged
R3Dzf merged 4 commits into
mainfrom
security/strict-gain-parser-20261012
Oct 12, 2026
Merged

R3Dzf merged 4 commits into
mainfrom
security/strict-gain-parser-20261012

Conversation

@R3Dzf

@R3Dzf R3Dzf commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Security finding

The public /validate and /solve endpoints previously passed user-supplied gain strings to sympy.sympify, which is not intended for untrusted Python expressions.

Changes

  • Replace direct sympify on request data with a limited AST-based mathematical parser (no eval).
  • Support common math syntax, symbols, scientific notation, caret powers, and whitelisted mathematical functions.
  • Bound input length, AST complexity and constant exponents.
  • Add security and compatibility regression coverage in the existing CI matrix.
  • Document supported expressions and unsupported constructs.

Validation

Wait for both Python 3.11 and 3.12 GitHub Actions jobs to pass before merge. This is a defense-in-depth change, not a claim of a full security audit.

@R3Dzf
R3Dzf merged commit 86d6522 into main Oct 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant