fix: add dangerous TF ops to SavedModel unsafe_tf_operators blocklist#341
Open
scruge1 wants to merge 1 commit intoprotectai:mainfrom
Open
fix: add dangerous TF ops to SavedModel unsafe_tf_operators blocklist#341scruge1 wants to merge 1 commit intoprotectai:mainfrom
scruge1 wants to merge 1 commit intoprotectai:mainfrom
Conversation
The SavedModel scanner's blocklist contained only ReadFile and WriteFile. TF has 1,462 raw_ops, many of which interact with the filesystem or execute arbitrary code. Added 9 dangerous ops: - MatchingFiles (HIGH): filesystem glob enumeration - WholeFileReader/V2 (HIGH): reads entire files from disk - InitializeTableFromTextFile/V2 (MEDIUM): reads files into TF tables - LMDBReader (MEDIUM): reads LMDB databases - PyFunc/PyFuncStateless/EagerPyFunc (CRITICAL): arbitrary Python execution - FileSystemSetConfiguration (MEDIUM): modifies filesystem config MatchingFiles is particularly dangerous as it survives SavedModel serialization and executes on tf.saved_model.load(), enabling filesystem enumeration (e.g., listing all .exe files in C:\Windows).
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.
Summary
unsafe_tf_operatorsblocklistReadFileandWriteFilewere blocked out of 1,462 raw_opsMatchingFilesenables filesystem enumeration that survives serialization and executes ontf.saved_model.load()Why
A SavedModel containing
tf.io.matching_files(theMatchingFilesop) passes modelscan with 0 issues but enumerates the filesystem when loaded. The scanner actively scans the.pbfile, encountersMatchingFiles, classifies it as a known safe op (since it's intf.raw_opsbut not in the 2-item blocklist), and reports no issues.Ops Added
Testing
5 unit tests verifying each dangerous op category is present in the blocklist and original ops (ReadFile, WriteFile) are preserved.