Learning to Detect Hardcoded Secrets

Numerous tools have been developed to uncover secrets and credentials in source code. However, they often rely on predefined rules that yield a high rate of false positives. We conduct an in-depth investigation into the performance of different AI models in secret detection. In non-generative models, we found that the choice of feature set greatly influences the performance in secret detection. These models demonstrated the best performance using the context feature, i.e., code surrounding the secret value. Particularly, CodeBERT outperforms other models with an MCC and F1-scores of 88% and 89%, respectively.When we applied the models to an unseen dataset of secrets, the top models were RF and CodeBERT, achieving an MCC score of around 65%. In generative models, we observed moderate performance (a maximum MCC of 63\%) and a high number of false positives, most of which occurred in the test path files. Our manual investigation of incorrect predictions revealed that LLMs tend to be cautious, flagging potential secrets to promote secure coding practices.

Institutions

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2025-11-21
DOI
https://doi.org/10.5281/zenodo.17669970
Primary Topic
Advanced Malware Detection Techniques
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Learning to Detect Hardcoded Secrets

Zenodo (CERN European Organization for Nuclear Research)
Advanced Malware Detection Techniques
article

Learning to Detect Hardcoded Secrets

article en

Abstract

Numerous tools have been developed to uncover secrets and credentials in source code. However, they often rely on predefined rules that yield a high rate of false positives. We conduct an in-depth investigation into the performance of different AI models in secret detection. In non-generative models, we found that the choice of feature set greatly influences the performance in secret detection. These models demonstrated the best performance using the context feature, i.e., code surrounding the secret value. Particularly, CodeBERT outperforms other models with an MCC and F1-scores of 88% and 89%, respectively.When we applied the models to an unseen dataset of secrets, the top models were RF and CodeBERT, achieving an MCC score of around 65%. In generative models, we observed moderate performance (a maximum MCC of 63\%) and a high number of false positives, most of which occurred in the test path files. Our manual investigation of incorrect predictions revealed that LLMs tend to be cautious, flagging potential secrets to promote secure coding practices.

Zenodo (CERN European Organization for Nuclear Research)
Clausthal University of Technology (DE)
Peace, Justice and strong institutions
Openalex Percentile: Top 40%
Advanced Malware Detection Techniques
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.