arXiv:2609.02983cs.CRSep 2026

Manuscript Offprint

arXiv:2609.02983

Boundary-Mutation Testing for Pattern-Based Secret Detection: A Rule-Level Method and Cross-Scanner Evaluation

Shweta Mishra

Shweta Mishra

Independent Researcher

Moradabad, India

shweta.mishra.research@gmail.com

Abstract—Pattern-based secret scanners are commonly validated with example-based fixtures that fix one variable: the text surrounding a credential. We introduce boundary-mutation testing to vary that context, generating credentials from each rule's own regular expression, embedding them in realistic source contexts, and classifying outcomes at the rule level rather than the tool level, yielding three detection metrics. Applied to three scanners — a 43-rule open-source scanner, Gitleaks 8.21.2, and TruffleHog 3.82.13 — detection in the primary subject holds at ≥0.9976\ge 0.9976 across ten contexts but collapses to 0.5233 when a credential ends in a hyphen. Five rules are affected: two, with fixed-count quantifiers, fail totally and deterministically; three, with variable-count quantifiers, backtrack and match a truncated credential; an entropy fallback rescues some failures but downgrades their severity. We validate a repair restoring full robustness with no new false positives, and report a caution: a plausible first attempt silently regressed two rules, caught only by re-running the same battery. Gitleaks has an unrelated, source-confirmed defect — a hard-coded terminator allowlist causing total misses for most credential types — while TruffleHog shows no boundary fragility but narrowest coverage. We report marginal, not conditional, failure probabilities: one common token format is structurally immune, another fails once in 64; on 292,527 lines of real code, the false-positive ordering inverts relative to the synthetic corpus. Because per-type detection is deterministic, the comparison unit is ten credential types, not hundreds of samples; no recall difference reaches significance, so we report the null result, not a ranking.

Index Terms—secret detection, credential leakage, mutation testing, metamorphic testing, regular expressions, empirical software engineering

I. INTRODUCTION

Credential leakage through source repositories is a persistent and largely preventable security failure [1]. The standard control is a pattern-based secret scanner: a table of regular expressions, usually paired with an entropy heuristic, applied to diffs or working trees. Gitleaks [2], TruffleHog [3], GitHub's hosted secret scanning, and the scanner studied here all belong to this family.

Such rule tables are commonly validated with example-based fixtures. A contributor adding a rule writes one or two credentials of the new shape into a test file and asserts they are detected; the scanner we study validates 43 rules with a 313-line fixture suite, and the practice is visible in the test suites of the other two tools as well. We do not claim to have surveyed the field exhaustively, and we do not need to: the weakness we identify follows from the structure of example-based fixtures, not from their prevalence.

That weakness is this. A regular expression does not match a credential in isolation; it matches a credential together with its surroundings, and anchoring assertions such as \b take effect precisely at the join between the two. Hand-written fixtures almost always place the credential in one canonical position — inside a double-quoted assignment, ending in an alphanumeric character. A rule that fails only when a credential is passed as a bare function argument, or only when its final character happens to be a hyphen, cannot be observed by a suite in which no fixture is written that way.

This paper introduces boundary-mutation testing to vary that surrounding context systematically. Three design choices distinguish it from writing more test cases. First, credentials are generated from each rule's own regular expression, so the corpus is derived from the artefact under test rather than from the experimenter's intuitions. Second, each credential is embedded in a battery of contexts, each one a way a credential legitimately appears in real source. Third — and this is what makes the defects visible — outcomes are classified at the rule level, distinguishing "the credential's own rule fired" from "something fired" (Fig. 1). The gap between those two is where a severity downgrade hides, and a tool-level binary metric cannot see it.

We apply the method to three independent scanners to test transferability and failure-mode diversity, not to produce a statistically powered ranking; Section XI-A shows the latter is not supported by ten shared credential types regardless of method. It transfers, and it exposes a distinct scanner-specific behaviour in each: a defect in the first two, and in the third a boundary-robust detector whose limits lie elsewhere. We report the mechanism behind each, the marginal (not merely conditional) probability that each affects a real credential, and a comparative evaluation in which we take some care to avoid disadvantaging a tool whose architecture differs from the others'.