Skip to content

[Security] Fix CodeQL alert #36: Deserialization of user-controlled data#88

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

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

Conversation

@colin-d-fried
Copy link
Copy Markdown
Owner

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

Summary

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

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

Fix Applied

See the diff for the specific secure coding change applied.

Fixes #38


Open with Devin

Note

Medium Risk
Changes the /import upload path from pickle.loads to json.loads, which is safer but may break existing clients that were uploading pickled payloads or non-JSON data.

Overview
Removes unsafe deserialization of uploaded data in the /import endpoint by replacing pickle.loads(content) with JSON parsing via json.loads(content).

This mitigates the CodeQL-reported CWE-502 issue, but also changes the accepted import format to JSON-only for that route.

Written by Cursor Bugbot for commit 8dad926. 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.


data = pickle.loads(content)
import json as _json
data = _json.loads(content)
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 private alias

Low Severity

The json module is imported inside the function body with an unnecessary underscore-prefixed alias (_json). There is no naming conflict with json in this scope, making the alias pointless and misleading (the underscore prefix conventionally denotes a private/internal name). The import also belongs at the module level alongside pickle, yaml, and marshal rather than being repeated on every call to import_data.

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 #36] Deserialization of user-controlled data

1 participant