Skip to content

fix(backend): constrain visualization target lambdas#1

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/vulnerability-reporting-workflow-65d7
Draft

fix(backend): constrain visualization target lambdas#1
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/vulnerability-reporting-workflow-65d7

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 26, 2026

Description of your changes:

Severity: High

The visualization API forwards user-controlled visualization fields into a notebook that runs inside the visualization server pod. A caller who can create visualizations controlled visualization.source and ROC arguments.target_lambda; the service interpolated source directly into Python syntax and evaluated target_lambda with eval, allowing arbitrary Python execution through non-custom visualization requests.

This change encodes source as a Python string literal and compiles ROC target lambdas only after AST validation. The validator keeps simple row arithmetic/comparison expressions but rejects calls, imports, attributes, comprehensions, and other executable syntax.

Primary location: backend/src/apiserver/visualization/types/roc_curve.py

Testing:

  • PYTHONPATH=backend/src/apiserver/visualization python3 -m unittest backend/src/apiserver/visualization/test_safe_target_lambda.py
  • PYTHONPATH=backend/src/apiserver/visualization python3 -m py_compile backend/src/apiserver/visualization/server.py backend/src/apiserver/visualization/safe_target_lambda.py backend/src/apiserver/visualization/types/roc_curve.py

Not run: full visualization server unittest in this runner, because system Python is missing tornado; pytest is also not installed.

Checklist:

Open in Web View Automation 

@herikwebb herikwebb added the bug Something isn't working label May 26, 2026 — with Cursor
Validate ROC target_lambda expressions before compiling them so visualization requests cannot execute arbitrary Python through function calls, imports, or attribute access. Encode visualization source values as Python string literals so non-custom visualizations cannot break out of generated notebook assignments.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
@cursor cursor Bot force-pushed the cursor/vulnerability-reporting-workflow-65d7 branch from db35689 to 8e51db4 Compare May 26, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants