Mohammad Ghafari
Research Subjects
Research Interests
Mohammad Ghafari has a total of 48 co-authors. Here are the top co-authors by number of shared publications:
- Oscar Nierstrasz
University of Bern, Bern, Switzerland
11 shared publications - Ehsan Firouzi
TU Clausthal, Germany
5 shared publications Haidar Osman
4 shared publications- Leonel Merino
Pontificia Universidad Catolica de Chile, Santiago, Chile
4 shared publications - Argianto Rahartomo
Technische Universitt Clausthal,Germany
2 shared publications Manuel Leuenberger
2 shared publications
Latest Publications
- Open Access
- 13 August 2026
- Published by Springer Nature in Empirical Software Engineering
- Vol. 32 (1) , 23
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 Random Forest 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. The investigation of incorrect predictions revealed that many are within test-path files and that LLMs tend to be cautious, flagging potential secrets to promote secure coding practices. We noted that prompt engineering reduces false predictions significantly, yet human intervention remains necessary.
- 13 August 2026
- Published by Springer Nature in Empirical Software Engineering
- Vol. 32 (1) , 23
Open AccessLearning 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 Random Forest 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. The investigation of incorrect predictions revealed that many are within test-path files and that LLMs tend to be cautious, flagging potential secrets to promote secure coding practices. We noted that prompt engineering reduces false predictions significantly, yet human intervention remains necessary.
- Open Access
- 16 October 2025
- Published by Elsevier in Journal of Systems and Software
- Vol. 232
Can generative AI detect and fix real-world cryptographic misuses?
- 16 October 2025
- Published by Elsevier in Journal of Systems and Software
- Vol. 232
Open AccessCan generative AI detect and fix real-world cryptographic misuses?
- Open Access
- 21 July 2025
- Published by Elsevier in Computers & Security
- Vol. 157
Metaverse security and privacy research: A systematic review
- 21 July 2025
- Published by Elsevier in Computers & Security
- Vol. 157
Open AccessMetaverse security and privacy research: A systematic review
- Open Access
- 26 June 2025
- Published by Association for Computing Machinery (ACM)
- p. 85-94
Security Bug Report Prediction Within and Across Projects: A Comparative Study of BERT and Random Forest
- 26 June 2025
- Published by Association for Computing Machinery (ACM)
- p. 85-94
Open AccessSecurity Bug Report Prediction Within and Across Projects: A Comparative Study of BERT and Random Forest
- 27 April 2025
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 287-291
Phishing Awareness via Game-Based Learning
The increased use of digital devices and applications has led to a rise in phishing attacks. We develop a serious game to raise awareness about phishing attacks and help people avoid these threats in a risk-free learning environment. This game targets three types of phishing—clone phishing, SMS phishing, and spear phishing—and uses a Large Language Model to generate dialogues and questions dynamically. It also incorporates state randomization and time-limited challenges to enhance the gameplay. We evaluated two groups of participants and found that those who played the game showed, on average, a 24 % increase in awareness and a 30 % boost in confidence.
- 27 April 2025
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 287-291
Phishing Awareness via Game-Based Learning
The increased use of digital devices and applications has led to a rise in phishing attacks. We develop a serious game to raise awareness about phishing attacks and help people avoid these threats in a risk-free learning environment. This game targets three types of phishing—clone phishing, SMS phishing, and spear phishing—and uses a Large Language Model to generate dialogues and questions dynamically. It also incorporates state randomization and time-limited challenges to enhance the gameplay. We evaluated two groups of participants and found that those who played the game showed, on average, a 24 % increase in awareness and a 30 % boost in confidence.
- Open Access
- 12 March 2025
- Published by Elsevier in Journal of Systems and Software
- Vol. 226
Poisoned source code detection in code models
- 12 March 2025
- Published by Elsevier in Journal of Systems and Software
- Vol. 226
Open AccessPoisoned source code detection in code models
- Open Access
- 24 October 2024
- Published by Association for Computing Machinery (ACM)
- p. 556-565
From Struggle to Simplicity with a Usable and Secure API for Encryption in Java
Cryptography misuses are prevalent in the wild. Crypto APIs are hard to use for developers, and static analysis tools do not detect every misuse. We developed SafEncrypt, an API that streamlines encryption tasks for Java developers. It is built on top of the native Java Cryptography Architecture, and it shields developers from crypto complexities and erroneous low-level details. Experiments showed that SafEncrypt is suitable for developers with varying levels of experience.
- 24 October 2024
- Published by Association for Computing Machinery (ACM)
- p. 556-565
Open AccessFrom Struggle to Simplicity with a Usable and Secure API for Encryption in Java
Cryptography misuses are prevalent in the wild. Crypto APIs are hard to use for developers, and static analysis tools do not detect every misuse. We developed SafEncrypt, an API that streamlines encryption tasks for Java developers. It is built on top of the native Java Cryptography Architecture, and it shields developers from crypto complexities and erroneous low-level details. Experiments showed that SafEncrypt is suitable for developers with varying levels of experience.
- Open Access
- 24 October 2024
- Published by Association for Computing Machinery (ACM)
- p. 582-588
ChatGPT’s Potential in Cryptography Misuse Detection: A Comparative Analysis with Static Analysis Tools
The correct adoption of cryptography APIs is challenging for mainstream developers, often resulting in widespread API misuse. Meanwhile, cryptography misuse detectors have demonstrated inconsistent performance and remain largely inaccessible to most developers. We investigated the extent to which ChatGPT can detect cryptography misuses and compared its performance with that of the state-of-the-art static analysis tools. Our investigation, mainly based on the CryptoAPI-Bench benchmark, demonstrated that ChatGPT is effective in identifying cryptography API misuses, and with the use of prompt engineering, it can even outperform leading static cryptography misuse detectors.
- 24 October 2024
- Published by Association for Computing Machinery (ACM)
- p. 582-588
Open AccessChatGPT’s Potential in Cryptography Misuse Detection: A Comparative Analysis with Static Analysis Tools
The correct adoption of cryptography APIs is challenging for mainstream developers, often resulting in widespread API misuse. Meanwhile, cryptography misuse detectors have demonstrated inconsistent performance and remain largely inaccessible to most developers. We investigated the extent to which ChatGPT can detect cryptography misuses and compared its performance with that of the state-of-the-art static analysis tools. Our investigation, mainly based on the CryptoAPI-Bench benchmark, demonstrated that ChatGPT is effective in identifying cryptography API misuses, and with the use of prompt engineering, it can even outperform leading static cryptography misuse detectors.
- 29 July 2024
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 1-5
Gameful Introduction to Cryptography for Dyslexic Students
Cryptography has a pivotal role in securing our digital world. Nonetheless, it is a challenging topic to learn. In this paper, we show that despite its complex nature, dyslexia—a learning disorder that influences reading and writing skills—does not hinder one's ability to comprehend cryptography. In particular, we conducted a gameful workshop with 14 high-school dyslexic students and taught them fundamental encryption methods. The students engaged well, learned the techniques, and enjoyed the training. We conclude that with a proper approach, dyslexia cannot hinder learning a complex subject such as cryptographv,
- 29 July 2024
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 1-5
Gameful Introduction to Cryptography for Dyslexic Students
Cryptography has a pivotal role in securing our digital world. Nonetheless, it is a challenging topic to learn. In this paper, we show that despite its complex nature, dyslexia—a learning disorder that influences reading and writing skills—does not hinder one's ability to comprehend cryptography. In particular, we conducted a gameful workshop with 14 high-school dyslexic students and taught them fundamental encryption methods. The students engaged well, learned the techniques, and enjoyed the training. We conclude that with a proper approach, dyslexia cannot hinder learning a complex subject such as cryptographv,
- Open Access
- 18 June 2024
- Published by Association for Computing Machinery (ACM)
- p. 600-603
LLM Security Guard for Code
Many developers rely on Large Language Models (LLMs) to facilitate software development. Nevertheless, these models have exhibited limited capabilities in the security domain. We introduce LLMSecGuard, a framework to offer enhanced code security through the synergy between static code analyzers and LLMs. LLMSecGuard is open source and aims to equip developers with code solutions that are more secure than the code initially generated by LLMs. This framework also has a benchmarking feature, aimed at providing insights into the evolving security attributes of these models.
- 18 June 2024
- Published by Association for Computing Machinery (ACM)
- p. 600-603
Open AccessLLM Security Guard for Code
Many developers rely on Large Language Models (LLMs) to facilitate software development. Nevertheless, these models have exhibited limited capabilities in the security domain. We introduce LLMSecGuard, a framework to offer enhanced code security through the synergy between static code analyzers and LLMs. LLMSecGuard is open source and aims to equip developers with code solutions that are more secure than the code initially generated by LLMs. This framework also has a benchmarking feature, aimed at providing insights into the evolving security attributes of these models.