Skip to content

Security: Input validation relies on assert, which can be disabled#2132

Open
tomaioo wants to merge 1 commit intogoogle-deepmind:mainfrom
tomaioo:fix/security/input-validation-relies-on-assert-which-
Open

Security: Input validation relies on assert, which can be disabled#2132
tomaioo wants to merge 1 commit intogoogle-deepmind:mainfrom
tomaioo:fix/security/input-validation-relies-on-assert-which-

Conversation

@tomaioo
Copy link
Copy Markdown

@tomaioo tomaioo commented Apr 22, 2026

Summary

Security: Input validation relies on assert, which can be disabled

Problem

Severity: Low | File: torax/__init__.py:L84

Validation of JAX_PRECISION uses assert. Python assert statements are removed when running with optimization flags (-O), which can bypass this check and allow unexpected values to propagate. While not directly exploitable on its own, this weakens defensive validation.

Solution

Replace assert with explicit runtime checks, e.g., if precision not in {'f32','f64'}: raise ValueError(...).

Changes

  • torax/__init__.py (modified)

Validation of `JAX_PRECISION` uses `assert`. Python `assert` statements are removed when running with optimization flags (`-O`), which can bypass this check and allow unexpected values to propagate. While not directly exploitable on its own, this weakens defensive validation.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 22, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jcitrin jcitrin requested a review from tamaranorman April 22, 2026 18:09
@jcitrin
Copy link
Copy Markdown
Collaborator

jcitrin commented Apr 22, 2026

@tomaioo thank you for your contribution. Please sign the CLA to be able to make contributions

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.

2 participants