Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 4 min read Case study mediumAdept

Protecting user data through source code analysis at scale

Meta's Anti-Scraping team encodes known scraping attack vectors as taint-analysis rules in its in-house static analyzers, Zoncolan for Hack and Pysa for Python, so potential vectors are flagged before code ships. Rules define sources (user-controlled parameters such as a result count or target ID) and sinks (data returned to the user), and a possible flow between them is raised as an issue for triage. In a mock followers endpoint, an uncapped count lets scrapers pull entire follower lists in one request and slip past rate limiting. The fix clamps count to a maximum, forcing scrapers into many more requests that rate limits then catch. Static analysis cannot catch scrapers that mimic legitimate usage, so it is one part of a broader defense.

Assumes: taint analysis basicsrate limiting

Related posts

  • Automating dead code cleanup

    Meta Engineering mediumAdept

    Meta's SCARF framework finds dead code by building a cross-language, symbol-level dependency graph from Glean and augmenting it with runtime usage data such as API endpoint logs, URI dispatch tables and async job invocations, then garbage-collects unreachable nodes, subgraphs and cycles. Switching from per-symbol classifiers to whole-graph analysis raised dead code removal in one large codebase by nearly 50%, at the cost of a longer indexing and data-pipeline cycle that makes prototyping harder. Over five years SCARF has deleted more than 100 million lines in over 370,000 change requests generated through CodemodService, with some languages auto-merged without review. BigGrep textual-reference checks act as a conservative fallback, accepting false negatives to avoid unsafe deletions.

  • From single pull requests to full software packages: Detecting malicious code at scale

    Datadog Engineering mediumAdept

    Datadog extended BewAIre, its LLM-based malicious code detector, from pull requests to full dependency packages by stacking a cheap filter model in front of an agentic investigation model. The agent uses GitHub APIs, osv.dev and SCA to check context such as author history and reverted commits. On 690 test diffs the two-stage design raised accuracy from 97.4% to 99.86% by cutting false positives from 17 to 0, and static typosquat-domain checks cover gaps in the filter. For large packages, giving the agent a codemap plus an on-demand ReadFile tool beat both forwarding the flagged chunk and rechunking, reaching 95.2% end-to-end accuracy with no runtime errors. Projected costs are about $0.025 per median package and $0.072 at p90, and a crawler polls npm and PyPI every 10 minutes, caching verdicts by hash and diffing against the previous version.

  • Separating the signal from the noise

    Engineering@Microsoft easyNovice

    Noisy static analysis rules train developers to ignore all tool findings, including critical ones, so engineering system owners should prune false-positive-prone rules. Microsoft's 1ES team found a Pareto effect in bug telemetry: a small number of rules, such as CA2202 "Do not dispose objects multiple times," produced most "Won't Fix, False Positive" resolutions. Deprecating those rules caused an immediate and sustained drop in false positive reports as developers came to trust tool findings more. The key recommendation is to analyze noise per rule rather than per tool, since the same tool can have highly valuable rules, like Code Analysis cryptography checks that developers fix over 99% of the time.

  • Automating product deprecation

    Meta Engineering mediumAdept

    SCARF (Systematic Code and Asset Removal Framework) is Meta's tooling for deprecating products by removing dead code and unused data, credited with deleting over 100M lines of code in five years and petabytes of data across 12.8M data types in 21 systems in one year. Engineers scope a deprecation by making only boundary decisions ("Flag Dependency" or "Add to Project"), and SCARF computes a daily-refreshed deletion roadmap that orders removals safely: mobile clients before GraphQL definitions, then business logic, schemas, and finally data. Static and dynamic usage signals block automated deletion of anything still in use. Engineers can triage or override those signals, for example deleting an endpoint that still gets trickle traffic, and generate targeted dependency-breaking code changes.

  • How Meta built large-scale cryptographic monitoring

    Meta Engineering mediumAdept

    Meta logs every operation in FBCrypto, its managed cryptographic library, without sampling by aggregating identical events into per-event counts in an in-process buffer and flushing them periodically to Scribe, with data landing in Scuba and Hive. The buffer is a folly::ConcurrentHashMap shared across threads. Randomized first-flush delays smooth write spikes, and derived-key operations are rolled up under the parent key name to cut volume while still giving a pessimistic count for detecting key overuse. The resulting dataset drives key rotation, inventories of weak and quantum-vulnerable algorithms for migration, migration-safety alarms based on success rates, and fleet-wide library version tracking. Remaining challenges include Scribe and Scuba capacity and flushing safely at shutdown.

The quest for software engineering knowledge.

Look:
Layout: