BANDA-Swift 0.4.0 · Issue 520 · 2 December 2026

Why BANDA skips the BusyBox buffer check

BusyBox reads the first character of argv[1]. The saved verifier report gives the buffer size (11 bytes) and the read width (1 byte), but leaves out where the pointer lies within that buffer. BANDA 0.4.0 relies on the report for that offset, so it skips the alarm.

In uthash, the failure happens later. BANDA starts checking whether a pointer is valid, reaches a call to memcmp, and has no rule for analyzing the call. Two such call sites blocked 83 alarm checks.

Who does what?

The benchmark compiles the C program to LLVM instructions. The base verifier, SVF-AE, examines those instructions and flags accesses it cannot prove safe. The benchmark saves its answers in an alarm file. This saved input is what “frozen base” means here.

BANDA reads both the alarm file and the compiled program. It builds its own graph of the program, locates the reported operation, and works backward to find the conditions under which the alarm could occur. This last step is called inference. To start it, BANDA needs a safety check whose terms have a meaning at that operation.

For example, a release test checks value != 1 inside a branch entered only when value == 0 || value == 2. A violation would require 1, and neither route into the branch allows it. BANDA records the alarm as locally refuted. Release test

More precisely, inference looks for entry states that could lead to a violation. It propagates conditions backward through assignments and intersects them with the conditions on incoming branches. It computes an outer approximation covering possible violations and an inner approximation containing only established violations. An empty outer set rules the alarm out. A reachable state in the inner set establishes a violation. A gap between the two can leave the alarm inconclusive. In the example above the violating condition is value == 1; intersecting it with either incoming branch leaves the empty set.

BusyBox: why is the offset missing when the index is zero?

In basename-2, the C code assigns __s2 = argv[1], then reads __s2[0] on line 1356. The compiled code loads a pointer from the argument array, adds zero bytes to that pointer, then reads one byte. The zero tells us how far the read is from __s2. To check the buffer boundary we also need to know where __s2 points relative to the start of the underlying allocation.

The frozen verifier’s offset calculation follows several kinds of pointer definitions, including address calculations and simple copies. It has no rule for following a pointer loaded from memory, which is how this example obtains __s2. This explains the missing value in the saved record by inspection of the compiled instructions and pinned verifier code. The record itself contains no trace of the verifier’s internal branches. Verifier offset calculation

{"offset.1869": null, "size.1869": [11,11], "width": [1,1]}

Here 1869 identifies the candidate buffer. The brackets give the lowest and highest possible values. The size is exactly 11 and the width is exactly 1. null means the offset calculation returned no interval. The report format can separately express an interval with an infinite endpoint.

Could BANDA still ask whether the offset is between 0 and 10?

Yes. That is the right safety condition. The limitation is in how v0.4.0 connects the word “offset” to a value. For an overflow alarm its input reader fills all three terms from numerical ranges in the saved record. It has no fallback that binds a missing offset to the program expression “access address minus start of this allocation.” Giving an unknown number a name would still leave inference without that connection.

What happened when we changed only the offset?

We replayed the same BusyBox instruction with the v0.4.0 binary three times. Only the first row uses the frozen evidence. The other two are controlled inputs, not claims about the real pointer.

OffsetWhat the numbers establishActual BANDA result
nullStarting byte unknownUnsupported before source lookup
[4, 7]All four starts fitBuilt the check, located the load, then stopped translating a subtraction
[4, 15]4–10 fit; 11–15 exceed the bufferBuilt the check, located the same load, then stopped at the same subtraction

Finite bounds are an admission rule in the release reader. The downstream range type already allows an open endpoint. For an ordinary load like this one, the evaluator asks two questions of the supplied numbers: is safety guaranteed for the whole range, and is safety possible anywhere in it? For [4, 15] those answers differ. The range alone supplies no program variable that a branch can narrow. BANDA can still reason about whether execution reaches the load. In these replays graph translation stopped both checks before a final safety decision. Range evaluation in the release

uthash: why does a comparison stop a pointer check?

In BER test2-2, line 824 compares a candidate hash-table key with the sought integer. This excerpt from the expanded C shows what the result controls:

if (memcmp((tmp)->hh.key, &i, sizeof(int)) == 0) { break; }

memcmp reads bytes from both addresses. A zero result exits the search loop; otherwise the search can advance to the next entry. When inference reaches this external call, BANDA looks for a rule describing its behavior. In v0.4.0 the lookup fails, and the current alarm analysis returns externalAPIResolution. A declaration alone gives no rule for how the return value relates to the bytes read.

In the release implementation the call descriptor carries a linkage name, arguments, result and a flag for an available SVF model. The resolver checks its supported call rules and the SVF-model fallback. An unresolved call throws unmodelled; the alarm workflow catches that error and reports unsupported. The trigger is an analysis step reaching a call it cannot process. A release test exercises this failure even with a constant safety property and no return value to track. That explains why a memcmp diagnostic by itself cannot tell us whether a particular proof needs its return value or memory reads. Resolver · Reached-call test

Replay identified 47 alarms stopped at line 824 of test2-2 and 36 at line 725 of test7-1. That is one missing operation at two source locations. The replay shows which call BANDA reached. It does not show that every alarm requires the comparison result for a proof, or that implementing the call would refute all 83.

Counts, overlapping causes and sample coverage

The issue author reran five cases with evidence retention enabled: BusyBox basename-2 and expand-2, and uthash BER test2-2, test7-1 and test4-3. These are the five available reruns. The selection rationale was unreported. They cover 952 of 23,003 unsupported overflow alarms (4.14%). The 83 uthash pointer-validity checks are counted separately.

Evidence in the saved alarmAlarms
One candidate with an offset field set to null551
Multiple candidates213
No offset field in the record186
Finite offset, insufficient size or length2

Among the 551, 501 had usable size and width or length. The other 50 also lacked a finite value for at least one of those fields. Among the 213 with multiple candidates, 195 had at least one null offset. None of the 213 had finite ranges for every field.

Missing key versus null. The verifier first asks which addresses this pointer might reference. It emits one offset/size pair for each address it can map to an object ID. No targets, an empty target set, or no mappable IDs can therefore leave no offset key. A null offset means the verifier got far enough to name an ID, but could not obtain a base object or calculate the displacement from it. The report alone cannot distinguish every internal branch. Verifier evidence generation

How much code would multiple targets require? There is already an experimental implementation in commit f3e760ec. Its only production change is in the report reader. It collects the smallest interval covering all offsets and another covering all sizes, and widens unknown values to open bounds. The existing evaluator can consume the result. This demonstrates a modest change for accepting the records. It does lose information: two valid (offset, size) pairs such as (2, 4) and (10, 12) become ranges that also allow the impossible combination (10, 4). Preserving that pairing or tracing the pointer back to the selected allocation is a different precision goal. The experiment was outside the tested v0.4.0 release. Experimental change and tests

Other BusyBox failures and what the verdicts mean

In expand-2, 11 dereference checks reached llvm.va_start.p0, the compiler operation that initializes access to a function’s variable arguments. BANDA lacked a model for it. Another 46 encountered unsigned integer division with no supported analysis rule. Three source locations matched multiple candidate operations, so BANDA could not choose the access to check. In basename-2, all three dereference checks stopped translating a subtraction operand labelled as 64-bit constant data. The diagnostic identifies node 56 in the program graph but omits the source location and exact constant.

Unsupported means BANDA lacked a required input or operation. Inconclusive means analysis completed and could establish neither verdict. Refuted means BANDA ruled out the reported violation. Confirmed means it established the violation can occur under the modeled entry conditions. Removing a blocker lets the check proceed; the eventual verdict is a separate question.

Transfer semantics for memcmp(a, b, n) == 0

This proposed model treats the comparison as a read-only guard. In state s, let N be the value of n after conversion to size_t. Let D(s) mean the call is defined under the C memory model. For a defined call, A(i) and B(i) are the unsigned bytes at offset i from the two pointers in that same state. The ranges may overlap.

Offsets are integers. Undefined calls belong to neither normal edge. For a defined call of length zero, the true edge is always taken and no bytes are read.

Forward and backward transfer

For either edge k, write Gₖ for the states satisfying its predicate. The guard preserves the state, so its exact forward image of input states P is P ∩ Gₖ. Its exact backward preimage of desired successor states Q is Q ∩ Gₖ. With γ mapping an abstract state to the concrete states it represents, the obligations are:

TransferSoundness condition
Forward overγ(Fₖ(P)) ⊇ γ(P) ∩ Gₖ
Backward underγ(Uₖ(Q)) ⊆ γ(Q) ∩ Gₖ
Backward overγ(Bₖ(Q)) ⊇ γ(Q) ∩ Gₖ

For a symbolic length, a backward-under transfer on the false edge may choose one mismatch position j, retaining Q and enforcing D(s), 0 ≤ j < N, and A(j) ≠ B(j). An over transfer must cover every feasible mismatch position. On the true edge, equality over a prefix known to lie within the range gives a necessary condition for over. Under must guarantee equality over the whole selected length, and may restrict N to a representable case to do so.

When the domain cannot express a refinement, either over transfer may return its input unchanged. The under transfer may return the empty state set. These rules describe the composite guard with its temporary result hidden. If subsequent code uses the return value, retain zero on the true edge. On the false edge its sign is determined by the first unequal unsigned-byte pair; C leaves its magnitude unspecified. A nonzero-only approximation suffices for over, but under must respect any successor constraint on the live result.

Operational backward rule

Input: the desired post-state Q, the taken edge (equal or unequal), and the approximation mode. Output: a pre-state. The call leaves memory unchanged, so begin with Q’s memory constraints. The rule below assumes the comparison result is used only by the guard.

backward(Q, edge, mode):
    S = filter(Q, call_is_defined(a, b, n), mode)
    split S by feasible lengths N
    for each selected N:
        T = filter(S, n == N, mode)
        if edge == equal:
            for i from 0 to N-1:
                T = filter(T, byte(a+i) == byte(b+i), mode)
            emit T
        else:
            for each selected i with 0 <= i < N:
                emit filter(T, byte(a+i) != byte(b+i), mode)
    combine emitted states in mode

Equal edge: Accumulate constraints in one state. Every byte comparison must hold. Unequal edge: Start each mismatch candidate from the same T. One unequal pair suffices, so combine the alternatives as a union. At N = 0 the equal edge emits T and the unequal edge emits nothing. An empty union is bottom.

Over mode: Cover every feasible length and every possible mismatch position. An exact union or an enclosing abstract join is sound. If enumeration is too expensive, use a symbolic condition or emit an enclosing state for the unexplored alternatives. Returning the incoming state for those alternatives is sound. An unrepresentable assumption may be skipped.

Under mode: Select any representable subset of lengths and mismatch witnesses. Each emitted state must imply Q, call definedness, and its entire branch condition. If an assumption cannot be enforced or established, discard that candidate. Keep an exact disjunction, retain selected disjuncts, or return bottom. An enclosing join that introduces unverified states is unsound here.

Both byte reads refer to the same pre-call memory, including aliases. For a symbolic N, an unequal-edge implementation may choose a symbolic witness j and enforce 0 ≤ j < N and A(j) ≠ B(j) directly. The equal edge requires the universal condition over the full range for under; a prefix alone is insufficient.

Original benchmark issue and reproduction details