Hybrid CNN-CodeBERT detects real credential leaks with 90% macro F1 and cuts false alerts 33%
The proposed three-class CNN-CodeBERT model achieves high detection performance while reducing false-positive alerts for placeholders and weak credentials
Software arXiv 29 May 2026 Method Prototype evidence
Published as “Separating Secrets from Placeholders: A Hybrid CNN-CodeBERT Framework for Three-Class Credential Leakage Detection”
Why it matters
Reducing alert volume by a third while preserving 93% recall can lessen triage fatigue and improve developer trust in automated secret-leak detection pipelines.
Summary
The three-class hybrid CNN-CodeBERT model cuts high-severity alerts by 33.0% (373→250) while keeping genuine-leak recall at 93%, achieving Macro-F1 0.90 and MCC 0.86 on a 9,426-snippet, ten-language dataset. Evidence comes from multiple random seeds, per-class metrics, and comparisons to adapted baselines, but the paper notes limited external validity to public repositories and snippet-level context.
What they found 4
- Overall detection performance is strong with high recall for genuine leaks.
“Evaluation on 9,426 manually annotated snippets across 10 programming languages demonstrates strong performance (Macro-F1: 0.90, MCC: 0.86, Genuine Leak recall: 0.93)”
- The three-class model reduces high-severity alerts by one-third without losing recall.
“this yields 373 alerts. In contrast, our threeclass model distinguishes placeholders from genuine leaks and produces 250 high-severity alerts (predicted Genuine only), corresponding to a 33.0% reduction in high-severity alerts while maintaining 93% recall for genuine leaks.”
- Semantic encoding via CodeBERT is the dominant component; removing it drops MCC dramatically.
“Removing it causes performance to drop substantially (MCC: 0.86 →0.57, F1: 0.90 →0.67)”
- The language adapter improves MCC for most languages, especially JavaScript (+7.7 pp).
“JavaScript achieves the largest gain, i.e., 7.7 percentage points (pp) increase in MCC”
Caveats 6
- Placeholder precision is lower than recall (0.78 vs 0.83), indicating notable false positives.
- The language adapter harms performance for PHP (-4.6 pp MCC) and shows a negligible drop for Python (-0.2 pp).
- Five genuine-leak instances are misclassified as placeholders, reflecting security-critical errors.
- Results may not fully generalize to proprietary or highly obfuscated code.
- The reported 33.0% alert reduction reflects test-set class proportions; actual reduction in deployment will vary with repository-level placeholder rates.
- Lower snippet-level recall (e.g., 30% for KEYSENTINEL) likely reflects adaptation to a finer-grained task rather than inherent method weakness.
What’s new here 4
- Introduces a three-class formulation (No Leak, Genuine Leak, Placeholder) to separate harmless placeholders from real secrets.
- Combines a character-level CNN with CodeBERT semantic encoding and a language adapter for cross-language robustness.
- Provides a manually annotated, multi-language dataset of 9,426 snippets (Cohen’s κ 0.89) released publicly.
- Demonstrates consistent performance across unseen languages via leave-one-language-out validation.