Pensar - auto fix for ML Pipeline Data Poisoning via Unvalidated Tweet Ingestion#13
Open
pensarappdev[bot] wants to merge 1 commit into
Open
Pensar - auto fix for ML Pipeline Data Poisoning via Unvalidated Tweet Ingestion#13pensarappdev[bot] wants to merge 1 commit into
pensarappdev[bot] wants to merge 1 commit into
Conversation
…Ingestion (CWE-20, ML02)
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.
Security issue fixed:
The ingestion of untrusted tweet data in
create_social_profile_sns(and related data flows) allowed unvalidated input, which could compromise downstream ML operations via data poisoning attacks as described.How it was addressed:
Provenance Tracking:
Every tweet ingested (from disk or scraped) receives a
_provenancefield indicating its source:"disk"or"scraped".Strict Input Validation:
A helper function
_is_valid_tweetwas added to verify (before use):Deduplication:
A
_deduplicate_tweetsfunction deduplicates tweets (by text and timestamp) before they are processed downstream or written to disk.Safe Disk Loading:
Tweets loaded from disk get revalidated and recleaned before being used. Invalid/anomalous tweets are skipped and a warning is logged.
Corpus Filtering:
Only validated/cleaned, deduplicated tweets are added to the analysis corpus (
all_tweets) and written back to disk.Side notes:
_provenanceanduserfields.More Details
all_tweetstraining corpus without any provenance tracking, validation, or anomaly detection. An attacker can deliberately craft malicious tweets—either by compromising one of the listed accounts or by creating bulk spam that the target account retweets—to poison the downstream embedding and clustering stages. This can:• Skew topic extraction or cluster assignment (integrity attack)
• Implant back-door trigger strings that later manipulate analytical outcomes
• Degrade model quality or cause misinterpretation of the generated Atlas map
This aligns with OWASP ML Top-10 ‘ML02 – Data Poisoning’ and maps to Improper Input Validation (CWE-20) because untrusted data is consumed directly in the training workflow.