Skip to content

Pensar - auto fix for Arbitrary Code Execution via Unsafe NumPy File Loading#12

Open
pensarappdev[bot] wants to merge 1 commit into
mainfrom
pensar-auto-fix-6ukW
Open

Pensar - auto fix for Arbitrary Code Execution via Unsafe NumPy File Loading#12
pensarappdev[bot] wants to merge 1 commit into
mainfrom
pensar-auto-fix-6ukW

Conversation

@pensarappdev
Copy link
Copy Markdown

@pensarappdev pensarappdev Bot commented May 7, 2025

Secured with Pensar

Security issue fixed:

  • In the Profile class's create_social_profile_sns method, the line that loaded local embeddings from a user-controlled file path used np.load(embedding_path) without specifying allow_pickle=False. This allowed possible arbitrary code execution if an attacker provided a malicious .npy file which used pickle-based deserialization (the default is allow_pickle=True, which is dangerous for untrusted files).
  • Fix applied: Changed embeddings = np.load(embedding_path) to embeddings = np.load(embedding_path, allow_pickle=False) to ensure only standard NumPy array data is loaded, disabling pickle deserialization and preventing unsafe code execution.
  • No other code or dependency changes were necessary or allowed according to the provided issue and scope.
More Details
Type Identifier Message Severity Link
Application CWE-502 embedding_path can be influenced by the caller. np.load() implicitly allows pickled object dtypes in several NumPy versions (or when the runtime’s default remains allow_pickle=True). A malicious .npy/.npz crafted with pickle payloads would be deserialized as soon as this line executes, leading to arbitrary code execution inside the Python process. No integrity check, signature validation, or allow_pickle=False safeguard is present, making this an instance of Insecure Deserialization (CWE-502) and a potential model-supply-chain attack vector. high Link

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.

0 participants