AI Scam & Fraud Detection
Relevant source files
The following files were used as context for generating this wiki page:
The AI Scam & Fraud Detection system is a multi-layered security framework designed to protect users within the MarketSage ecosystem. It utilizes behavioral analysis, statistical anomaly detection, and heuristic-based engines to identify fraudulent listings, malicious sellers, and phishing attempts in real-time. By integrating weighted risk assessments and user-defined sensitivity thresholds, the system provides dynamic protection across various e-commerce platforms.
The system's scope extends from basic keyword filtering to advanced threat intelligence, including the detection of sophisticated tactics like "bait and switch" and artificial price manipulation. It serves as the core security layer for the MarketSage MVP, ensuring that product discoveries and seller profiles are vetted before user interaction.
Sources: src/common/models/scamDetectionModel.ts:1-25, src/core/security/AdvancedThreatDetection.ts:1-15, development/frontend/index.html:15-25
Architecture and Core Components
The detection architecture is divided into three primary tiers: the high-level SecurityAnalyzer for general metrics, the ScamDetectionModel for heuristic processing, and the AdvancedThreatDetection service for deep security analysis.
System Data Flow
The following diagram illustrates how product data flows through the various detection engines to produce a final risk assessment.
The ScamDetectionModel acts as a coordinator, running multiple specialized engines in parallel to evaluate different aspects of a listing.
Sources: src/common/models/scamDetectionModel.ts:35-65, src/background/services/protect/securityAnalyzer.ts:34-55
Scoring and Heuristics
The system utilizes a weighted scoring mechanism. Each heuristic contributes a score (0.0 to 1.0) which is then multiplied by a weight defined in the user's preferences.
Core Heuristics
| Heuristic ID | Category | Description | Default Weight |
|---|---|---|---|
price_anomaly | Pricing | Identifies prices significantly outside market average. | 0.8 |
seller_history_analysis | Seller | Analyzes past behavior, ratings, and tenure. | 0.75 |
review_pattern_analysis | Reviews | Detects unusual timing or sentiment in reviews. | 0.75 |
image_quality_analysis | Visual | Checks for manipulated or low-quality product images. | 0.6 |
specification_anomalies | Product | Flags unrealistic specs for the given price/category. | 0.7 |
Sources: src/common/models/scamDetection/userPreferences.ts:5-80, src/common/types/scamDetection.ts:21-35
Risk Level Determination
The final probability is mapped to one of four risk levels:
- LOW: Probability < 0.3
- MEDIUM: Probability 0.3 - 0.6
- HIGH: Probability 0.6 - 0.8
- CRITICAL: Probability > 0.8
Sources: src/common/models/scamDetectionModel.ts:182-187
Advanced Threat Detection
Beyond simple heuristics, the AdvancedThreatDetection service handles sophisticated security threats using a dedicated threat intelligence database.
Threat Intelligence Components
- Known Threat Signatures: Patterns of recognized malicious activity.
- Blacklisted Sellers: A persistent set of IDs known for fraudulent behavior.
- Behavioral Patterns: Historical data used to identify anomalous user or seller actions.
Sources: src/core/security/AdvancedThreatDetection.ts:58-75
Detection Logic Flow
The sequence below shows how the service processes a product to identify complex threats.
Implementation Details
Security Metrics Calculation
The SecurityAnalyzer class calculates an overall risk score by weighting specific areas of concern.
private calculateOverallRisk(
sellerRisk: number,
priceRisk: number,
listingRisk: number
): number {
return (
(1 - sellerRisk) * SecurityAnalyzer.RISK_WEIGHTS.SELLER_HISTORY +
priceRisk * SecurityAnalyzer.RISK_WEIGHTS.PRICE_ANOMALY +
listingRisk * SecurityAnalyzer.RISK_WEIGHTS.LISTING_QUALITY
);
}
Sources: src/background/services/protect/securityAnalyzer.ts:115-125
Review Pattern Analysis
The ReviewAnalyzer identifies fraudulent feedback through several mockable checks, such as review spikes and sentiment inconsistency.
- Review Spike: Detects an unusual volume of 5-star reviews within a 24-hour window.
- Sentiment Inconsistency: Compares the text content against the numerical rating.
- Repetitive Text: Flags reviews that share identical or highly similar phrasing.
Sources: src/common/models/scamDetection/reviewAnalyzer.ts:5-30
Configuration and Preferences
The system is highly configurable via the ScamDetectionPreferences class, allowing users to toggle specific heuristics and adjust the global sensitivity threshold (default is 70%).
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Whether a specific heuristic is active. |
weight | number | 0.0 - 1.0 | The impact of a heuristic on the total score. |
globalThreshold | number | 70 | Overall sensitivity multiplier (0-100). |
zScoreThreshold | number | 2.5 | Std. deviations for statistical anomalies. |
Sources: src/common/models/scamDetection/userPreferences.ts:140-165, src/common/types/scamDetection.ts:13-20
Summary
The AI Scam & Fraud Detection system provides a robust defense by combining standard e-commerce heuristics with advanced threat intelligence. Its modular design allows for parallel execution of detection engines, while the weighted scoring system ensures that high-confidence indicators (like price anomalies or blacklisted sellers) have a significant impact on the final risk assessment. This architecture allows the platform to scale security measures according to user preferences and emerging market threats.