Blog · 2026-10-30

Proving a sink safe from its callers — and the bug a mutation test caught

How cross-file call-site analysis cut C# SQL false positives on Juliet from 48.6% to 27.3%, after a first version that was faster to improve and wrong.

Static analysers have two ways to be wrong about a helper function. Treat its parameters as clean and you miss every injection that arrives through it. Treat them as attacker-controlled and you report every concatenation inside it — including the ones that only ever receive constants. The second mistake is the one that makes developers stop reading findings.

On the NIST Juliet C# suite our SQL-injection rule had a false-positive rate of 48.6%. Almost every false positive had the same shape: a public sink method in one file, called from another file with a hard-coded string.

// CWE89_..._51b.cs                                  // CWE89_..._51a.cs
public static void GoodG2BSink(string data, ...)     string data = "foo";
{                                                    CWE89_..._51b.GoodG2BSink(data, req, resp);
    cmd.CommandText = "update users set hitcount=hitcount+1 where name='" + data + "'";
}

Asking the callers

Our engines already run a proof pass: every method is walked with its parameters tainted, and a sink whose argument stays clean even then is proven safe, which also withdraws the line-level pattern match on that line. The weakness was the first assumption. A public method's parameters were always assumed tainted, because any caller anywhere could reach it.

But in a pull-request scan we can see the callers. So the batch now computes, for every Type.Method other files call, what each call site passes — under the same pessimistic proof assumptions — and iterates that to a fixed point so a constant passed through a relay helper stays a constant. A method called from other files is then seeded from those masks instead of from "anything". It still starts fully tainted when it looks like an entry point: an attributed action, a controller, hub or page class, an event handler, or a method nothing in the batch calls.

The bug the mutation test caught

The first version cut the false-positive rate to 14% — and quietly dropped detection from 100% to 97.3%. Every lost case was Juliet flow variant 67, where the tainted value travels inside an object:

Container dataContainer = new Container();
dataContainer.containerOne = data;      // tainted
Helper_67b.BadSink(dataContainer, ...); // the call site's mask for dataContainer was empty

The engine does not follow a field write into the object's own mask, so the call site looked clean and a vulnerable sink was "proven" safe. That is the worst failure a proof can have. The fix is conservative: an object variable its method writes into — a field, an indexer, an Add-style call — counts as carrying anything. Detection went back to 100%, and the false-positive rate settled at 27.3%: a smaller improvement than the broken version, and a real one.

Closing the last surviving mutants found a second, older bug: for a named argument such as Find(conn: x, data: y) the engine evaluated the argument's name instead of its value, and cross-file facts matched arguments by position. Both are fixed, with tests.

What is left

The remaining C# false positives are mostly flow variant 61, where the constant comes back as the return value of a method in another file. Following return values across files in the proof pass is next. The current numbers are on the benchmark report.