leeky.sh

Back

The Pareto Principle#

The Rule: An unequal relationship exists between inputs and outputs. For example, 20% of your effort often drives 80% of your results, or 20% of customers generate 80% of a business's sales

In 1896, an economist in Italy noticed that 20% of Italy's population owned 80% of it's land.

The pareto principle is everywhere.

You probably wear about 20% of your clothes 80% of the time.

20% of the apps on your phone take up 80% of your screen time.

Most of your text messages go to a handful of people.

A restaurant menu, a few dishes make up most of the orders.

In 2002, Steve Ballmer said their Windows Error telemetry data showed that 20% of bugs caused 80% of all crashes. 1% of bugs caused half.

Microsoft used this data to decide which fixes to prioritize.

This made me want to find an answer to the question:

How does the pareto principle fit into Agentic Security?

Agentic Security#

I've spent the past 2 years using agents to find security vulnerabilities in codebases. Starting off with RAG's, then AST code-graphs...I've built variant hunting workflows, novel agent workflows, tools to grab relevant context. When it comes to using agents to find security issues in code, I know every trick and technique to get the most bang for your buck.

But there's still an elephant in the room, every AI-native security engineer struggles to tackle

The Monolith#

A black monolith standing among rocks and apes at dawn, from 2001: A Space Odyssey

Large codebases can be a problem. Monorepos are an even bigger problem.

There's context size, step limits, overall budget concerns, you name it.

How would pareto fit ino this? 80% of the security vulnerabilities are in 20% of the code.

Fine, but HOW do you find that 20%?

My git instinct said the answer had to be commit activity. I pulled out Claude and built heatmap, a tool that ranks every file using commit history, code complexity, and ownership.

The idea: generate a heatmap, take the hottest 20% of files, and backtest against findings from bug bounty reports, SAST, internal pentests and variant analysis.

Does git history predict where vulnerabilities are?#

I wasn't the first person to ask this question, but it's been a long time since someone did.

Nagappan and Ball (2005) ↗ used relative code churn to predict defect density in Windows Server 2003.

Shin et al. (2011) ↗ found that complexity, churn, and developer-activity metrics predict vulnerabilities in Firefox and RHEL.

Tackling the monolith#

An ape reaching out to touch the monolith, from 2001: A Space Odyssey

This monorepo was the perfect test candidate. Hundreds of findings over years, through SAST, internal findings and an active bug bounty program with 175+ rewards.

Heatmap turns 13,000 files into 2,600.

The top 20% hottest files had 80% of the findings

The top 10% had 61%

Files reviewedFiles with findings covered
Hottest 10% (1,308 files)61.5%
Hottest 20% (2,616 files)78.4%

Figure 1

A fifth of the repo covers four fifths of the files with findings

Top: the 13,080 files heatmap ranked, hottest first. Bottom: the files with known findings, split by where in that ranking they fell. Reviewing at random, the hottest 20% would hold about 20% of them.

Hottest 10% of filesNext 10%Everything else
All files13,080 rankedFiles with findingsby where they rankedThe hottest 10% of files hold 61.5% of the files with findingsThe next 10% hold another 16.9%Hottest 10%: 1,308 files10%Next 10%: 1,308 files10%The other 80%: 10,464 filesthe other 80% of files61.5% of the files with findings ranked in the hottest 10%61.5%16.9% ranked in the next 10%16.9%21.6% ranked in the other 80%21.6%The hottest 20% of fileshold 78.4% of the files with findings

The lumpiness shows in the raw data too.

In the smallest tenth of files by size, 0.08% had findings. In the largest tenth, 11% did.

How AI agents can use heatmap#

Figure 4

Where the ranking plugs into the agents

The scoring workflow returns the top-N files, keyed to the commit it scored. On the right, four places the agents can use that ranking.

EXISTS TODAYRepositoryat one commitheatmapscores every fileTop-N fileskeyed to the commitScoping reconstart agents on the hottest filesVariant expansionwalk candidate sites in rank orderPR reviewpercentile sets how hard to lookPrompt contextpercentiles beside the code

The obvious use is scoping recon: start the agents on the hottest files instead of letting them pick their own entry points.

When variant hunting, agents can search through the hottest files first instead of going folder by folder.

During PR reviews, a file's hottness can be a signal for how hard a model should look at a diff that touches it.

"This file is in the 99th percentile for commit count and the 95th for complexity" is a reason for an agent to look harder, and it's metadata about the codebase an agent wouldn't think of to check on it's own

Check it on public code#

You can't check the backtest, but you can check this. For a concrete example, I ran a heatmap scan of pallets/click ↗ at commit 2247b35, every file sized by its lines of code and colored by its risk score. These are its top five files:

RankFileRiskChurnComplexity
1src/click/core.py92.598.369.4
2src/click/types.py89.494.867.8
3src/click/termui.py87.090.971.1
4.github/workflows/tests.yaml82.590.650.0
5src/click/_termui_impl.py82.087.660.0

Each score is a percentile within the scan, so it's relative: 92.5 says core.py sits near the top of click, not that it's dangerous.

heatmap explain shows how any score was built. core.py is first because 237 commits have touched it, more than any other file in click, and it has the highest total cyclomatic complexity.

heatmap is fast, Django's 35,000 commits take about five seconds.

Try it#

heatmap scan path/to/repo
bash