bug: Block read_pickle and class definitions, restrict custom CSV field to read_csv() only#6257
Draft
chloebyun-wd wants to merge 1 commit intomainfrom
Draft
Conversation
…ld to read_csv() only
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances security by introducing a specialized validator for custom CSV reading and expanding the list of forbidden Python patterns to prevent unsafe deserialization and class definitions. A security concern was raised regarding the regex for read_pickle, suggesting a broader match to prevent bypasses via variable assignment.
| { pattern: /\b__module__\b/g, reason: '__module__ (module reflection)' } | ||
| { pattern: /\b__module__\b/g, reason: '__module__ (module reflection)' }, | ||
| // Unsafe deserialization — read_pickle() executes arbitrary Python objects | ||
| { pattern: /\bread_pickle\s*\(/g, reason: 'read_pickle() (unsafe deserialization / RCE)' }, |
Contributor
There was a problem hiding this comment.
The regex /�read_pickles*(/g only matches direct function calls. It can be bypassed by assigning the function to a variable. Using /�read_pickle�/g is more secure as it catches any reference to the forbidden function.
Suggested change
| { pattern: /\bread_pickle\s*\(/g, reason: 'read_pickle() (unsafe deserialization / RCE)' }, | |
| { pattern: /\bread_pickle\b/g, reason: 'read_pickle (unsafe deserialization / RCE)' }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.