Skip to content

fix(juliet): print sinks read their data; score a leak only for CWE-401 - #97

Open
GuilhermeBn198 wants to merge 1 commit into
developfrom
fix/juliet-print-sinks
Open

GuilhermeBn198 wants to merge 1 commit into
developfrom
fix/juliet-print-sinks

Conversation

@GuilhermeBn198

Copy link
Copy Markdown
Collaborator

Problem

On the native Juliet runs of the JBCS 9.0 campaign, CWE-416 came out at precision 32.7% and recall 48.6%. The cause is two defects in the harness, not in Map2Check.

  1. Print sinks were no-ops. printLine, printWLine, printStructLine and printBytesLine in tests/juliet/juliet_stubs.c did nothing, so a flaw whose only use is the print never happened. 36 of 70 CWE-416 bad programs (malloc_free_char, _wchar_t, _struct, return_freed_ptr) came out TRUE. The families that read data[0] before the call (int, long, int64_t) were 30/30. The stub itself recorded this bias as pending.
  2. A leak counted as the CWE's flaw. The runner collapsed every FALSE-* into FALSE. Juliet's programs for the memory CWEs leak on purpose ("POTENTIAL INCIDENTAL - Possible memory leak"), the fixed ones too. All 70 FPs of CWE-416, 30 of CWE-122 and 10 of CWE-476 are FALSE-MEMTRACK, and 37 TPs were a leak rather than the flaw.

Change

  • The pointer print sinks read what they would print, as io.c does, without the external call.
  • The CSV keeps the fine-grained verdict. classify_for_cwe (tests/lib/verdict_classifier.sh) scores it against the CWE, and a leak counts only for CWE-401.
  • tests/juliet/rescore_juliet.sh rescores a finished run from its raw logs, without running it again.
  • CASTLE is unchanged: it has no FALSE-MEMTRACK verdict.

Evidence

  • Rescoring the campaign data: 0 FP on every memory CWE (121, 122, 415, 416, 476, 761).
  • CWE-416 rerun with the new stubs, same sample, same build: 68/70 bad FALSE-DEREF, the 70 good runs FALSE-MEMTRACK (TN). Precision 100%, recall 97.1% (was 32.7% / 48.6%). Longest run 5.5 s.

Tests

  • test_verdict_classifier.sh: 38/38, 14 of them new scoring cases.
  • test_juliet_stubs.sh (new, in CI): 5/5. On the old stubs 4 of the 5 fail.
  • test_juliet_sampling.sh: 18/18.

Two harness defects in the native Juliet runs, found on the CWE-416 results
of the JBCS 9.0 campaign (precision 32.7%, recall 48.6%).

The print sinks of juliet_stubs.c were no-ops, so a flaw whose only use is the
print never happened: 36 of 70 CWE-416 bad programs (use after free through
printLine or printStructLine) came out TRUE. printLine, printWLine,
printStructLine and printBytesLine now read what they would print, as io.c
does, without the external call.

The runner collapsed every FALSE-* into FALSE and counted it as the CWE's
flaw. Juliet's programs for the memory CWEs leak on purpose ("POTENTIAL
INCIDENTAL - Possible memory leak"), the fixed ones too, so all 70 fixed
CWE-416 programs scored FP on a FALSE-MEMTRACK, as did 30 of CWE-122 and 10
of CWE-476; 37 TPs were a leak, not the flaw. The CSV now keeps the
fine-grained verdict, and classify_for_cwe counts a leak only for CWE-401.

rescore_juliet.sh rescores a finished run from its raw logs, without running
it again. On the campaign data it gives 0 FP on every memory CWE; CWE-416
rerun with the new stubs: 68/70 bad FALSE-DEREF, precision 100%, recall 97.1%.

Tests: test_verdict_classifier (14 scoring cases), new test_juliet_stubs
(4 of 5 cases fail on the old stubs).
@GuilhermeBn198

GuilhermeBn198 commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Full rerun of the memory CWEs with this branch (213347323): 4360 runs, same sample and same install_jbcs build as the JBCS 9.0 campaign. Scored with rescore_juliet.sh.

CWE TP FP TN FN Inconclusive Precision Recall: campaign (rescored) → this branch
121 1047 0 1126 60 87 100% 85.9% → 94.6%
122 494 0 647 72 147 100% 78.9% → 87.3%
415 59 0 54 1 6 100% 96.7% → 98.3%
416 66 0 70 4 0 100% 42.9% → 94.3%
476 80 0 90 10 0 100% 88.9% → 88.9%
761 20 0 100 80 40 100% 20.0% → 20.0%
  • CWE-121: inconclusive runs dropped from 478 to 87. The read in the print sink reaches the overflow before KLEE runs out of budget, which turned 354 UNKNOWN, 42 TIMEOUT and 40 FN into TP.
  • Cost: 16 TN became inconclusive (121: 5, 122: 5, 415: 6), and 4 TP of 122 became UNKNOWN.
  • CWE-416: 66/70 here against 68/70 in the first test run. In a few cases the order of exploration decides whether the leak or the use after free is reported first.
  • CWE-761: its recall of 20% is a separate problem and is not addressed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant