Skip to content

[Security] Fix CodeQL alert #35: Deserialization of user-controlled data#87

Open
colin-d-fried wants to merge 1 commit into
mainfrom
security/codeql-35-deser-session-fix
Open

[Security] Fix CodeQL alert #35: Deserialization of user-controlled data#87
colin-d-fried wants to merge 1 commit into
mainfrom
security/codeql-35-deser-session-fix

Conversation

@colin-d-fried
Copy link
Copy Markdown
Owner

@colin-d-fried colin-d-fried commented Mar 26, 2026

Summary

Fixes CodeQL alert #35: Deserialization of user-controlled data

Field Value
Severity critical
File vulnerable_deserialization.py
CWE CWE-502
Alert CodeQL Alert #35

Fix Applied

See the diff for the specific secure coding change applied.

Fixes #37


Open with Devin

Note

Medium Risk
Reduces RCE risk by replacing pickle.loads on user-provided session data with JSON parsing, but may change accepted session formats and error behavior for the /session endpoint.

Overview
Mitigates CodeQL CWE-502 by changing the /session restore path in vulnerable_deserialization.py to parse user-provided session data with json.loads instead of pickle.loads.

This removes insecure deserialization from that endpoint, trading it for a JSON-only session payload expectation.

Written by Cursor Bugbot for commit da5d233. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


session = pickle.loads(session_data.encode())
import json as _json
session = _json.loads(session_data)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary inline import with unconventional alias

Low Severity

The json module is imported inside the function body and aliased as _json, even though there is no naming conflict with json in this file. The underscore-prefixed alias is unconventional and misleading (suggesting a private symbol). The import belongs at the top of the file alongside the other standard library imports (pickle, yaml, marshal).

Fix in Cursor Fix in Web

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.

[CodeQL #35] Deserialization of user-controlled data

1 participant