Rule

zero-amount-unguarded-map-debit-review

Review an amount-zero successful numeric Map debit whose exact lookup has unknown prior membership.

Release v0.1.1View Markdown

Specimen 77 of 96 · Other active opt-ins / Token, coin and value transfers

Severity
info
Confidence
high
Maturity
experimental
Selection
Opt-in
Policy intent
not required
Release
v0.1.1
Engine facts used
entry-zero-history exact-map-lookup numeric-subtraction ordered-writes

Selection and scope#

Not selected by default. Select it with --detectors or the detectors list in nightshade.json. Either one replaces profile selection, so list every rule you want.

Shell
./.nightshade/node_modules/.bin/nightshade ./contracts --detectors zero-amount-unguarded-map-debit-review
./.nightshade/node_modules/.bin/nightshade detector show zero-amount-unguarded-map-debit-review

The first command runs only this rule; --detectors takes a comma-separated list. The second prints the rule's metadata from your installed version.

Severity is review priority. It does not express exploitability or impact. Confidence is detector metadata, not a probability. All built-in rules are experimental.

Compiler scope: the engine supports the pinned profiles 0.28.0, 0.29.0, 0.30.0, 0.31.1, 0.33.0-rc.2, 0.34.0, 0.35.0-rc.1 and 0.35.0, with ZKIR2 by default. Support for this rule can be narrower; the rule documentation below states any narrower scope.

Corpus checks#

Synthetic corpus checks for this rule in the 0.1.1 proof run. A check counts only with compiler acceptance and complete analysis.

Positive detectedCorrected quietLookalike quietOther negative quietIncomplete
2/22/22/20/00

No deviations were recorded for this rule.

These are behavior checks on synthetic fixtures, not a precision or recall estimate. See evaluation.

Rule documentation#

From docs/detectors/zero-amount-unguarded-map-debit-review.md at v0.1.1.

Availability: opt-in, no policy required. Severity: info. Confidence: high for the supported static source relationship.

Select with --detectors zero-amount-unguarded-map-debit-review. The observer selects actual debit operands from an ordinary successful invocation, then fixes an unchanged numeric entry parameter to zero. Literal-zero APIs use ordinary histories. It reports a numeric Map lookup whose exact immutable result is the minuend of that subtraction and is written to the same exact entry, without an intervening overlapping mutation, when membership was unknown before the lookup. Each lookup retains its own occurrence identity and helper arguments retain their actual values. One complete qualifying history suffices.

Same-entry guards and exact prior insertions are quiet. Parent-only or different key membership does not establish the selected inner entry. A later guard does not establish membership before an earlier lookup. Positive-only APIs, addition, unrelated amounts, transformed debit parameters, different write keys and intervening may-alias writes do not qualify. An earlier successful same-entry lookup can establish membership, making a later debit read quiet.

Unknown membership is not missing membership. The rule does not establish intended zero semantics, initial absence, runtime lookup failure, transaction feasibility or impact. Initial storage remains unknown; cross-invocation application invariants are not inferred. Intentional zero APIs can match.

The dedicated observer retains explicit empty operation sequences. Missing lookup origins, operands, ordered writes or invocation evidence, reached checkpoints and exhausted budgets produce diagnostics. Ordinary analysis and the existing zero-membership policy remain unchanged.

Incomplete and rejected inputs provide no absence guarantee.

Suppress a match#

If a match is intentional, suppress it on the line before with the exact rule ID and a reason of at least eight characters:

Compact
// nightshade-disable-next-line zero-amount-unguarded-map-debit-review -- Reason this match is intentional

Diagnostics cannot be suppressed, and an unmatched directive for a selected rule makes analysis incomplete. See configuration for fingerprint suppressions and baselines.

References#