Towards Precise Reporting of Cryptographic Misuses
Yikang Chen
Network and Distributed System Security (NDSS) Symposium 2024 · Day 1 · Applied Cryptography
Overview
Modern software relies heavily on cryptographic Application Programming Interfaces (APIs) to secure data and communications. However, developers frequently misuse these complex APIs, leading to critical vulnerabilities. To address this, a significant body of research has focused on developing static analysis tools that detect cryptographic API misuses. While these tools aim to improve security, they often generate an overwhelming number of alarms, many of which are false positives or ineffectual warnings that do not represent true vulnerabilities or actionable issues. This high rate of inaccurate alerts significantly hinders developer adoption and trust in these security tools.

Key moments
- 0:00 Introduction: The problem of cryptographic misuses
- 2:00 Prevalence of false alarms and tools analyzed
- 4:00 Background: False alarms deter developer adoption
- 6:00 Methodology: FPs vs. Ineffectual True Positives
- 6:45 Datasets used for detector evaluation
- 8:00 Two-phase analysis: sampling and root-cause analysis
Towards Precise Reporting of Cryptographic Misuses
Speakers: Yikang Chen
Conference: NDSS Symposium
YouTube: https://www.youtube.com/watch?v=xwrrReZeUxc
Overview
Modern software relies heavily on cryptographic Application Programming Interfaces (APIs) to secure data and communications. However, developers frequently misuse these complex APIs, leading to critical vulnerabilities. To address this, a significant body of research has focused on developing static analysis tools that detect cryptographic API misuses. While these tools aim to improve security, they often generate an overwhelming number of alarms, many of which are false positives or ineffectual warnings that do not represent true vulnerabilities or actionable issues. This high rate of inaccurate alerts significantly hinders developer adoption and trust in these security tools.
The talk "Towards Precise Reporting of Cryptographic Misuses" by Yikang Chen from the NDSS Symposium directly confronts this critical challenge. The research meticulously investigates the rule violations reported by three state-of-the-art academic static detectors—CryptoGuard, CogniCryptSAST, and CryptoREX—alongside their underlying rules, models, and implementations. The primary objective is to bridge the substantial gap between reported misuse alarms and actual vulnerabilities, understand why developers write code flagged as misuses, and, most importantly, identify concrete improvement directions for enhancing the precision and usability of cryptographic misuse detectors.
This work is crucial because it shifts the focus from merely finding more misuses to ensuring the quality and actionability of reported alarms. By performing an in-depth technical analysis and root-cause investigation across multiple detectors, the paper reveals a broad spectrum of false alarm patterns. It provides empirical evidence that many reported "misuses" are not, in fact, security flaws, but rather artifacts of detector limitations, imprecise modeling, or a failure to account for real-world development contexts and mandated standards. The findings offer invaluable insights for both tool developers and security practitioners aiming to build and utilize more effective cryptographic misuse detection capabilities.
Background
▶ Watch: Introduction: The problem of cryptographic misuses (0:00)
The landscape of cryptographic API misuse detection has evolved considerably over the past decade. Early static analysis tools, such as MalloDroid, extended existing frameworks like Androguard to analyze SSL/TLS API usage in Android applications. CryptoLint then formalized six common cryptographic API usage rules, which were later adopted and expanded upon by tools like CryptoREX for analyzing IoT firmware. More recently, advanced static detectors like CogniCryptSAST and CryptoGuard emerged, offering more sophisticated flow-, context-, and field-sensitive analysis for Java and Android applications, coupled with larger and more intricate rule sets. Complementing these static approaches, dynamic detectors such as Crylogger monitor API usage during runtime to identify violations.
Despite these advancements, a persistent challenge in static analysis, particularly in security, has been the prevalence of false alarms. Prior research, including a 2013 user study by Johnson et al., unequivocally demonstrated that a high volume of false positives significantly deters developers from adopting static analysis tools. While efforts have been made to reduce false negatives in cryptographic misuse detection, there has been a notable lack of independent, in-depth research specifically focusing on the root causes and patterns of false alarms. Previous small-scale inspections often failed to uncover critical issues within detector rules, models, and implementations, leading to an overestimation of actual misuses and vulnerabilities. For instance, the study highlights that a substantial portion of alarms related to constant keys and passwords reported by academic detectors were, in fact, false positives caused by implementation bugs within the detectors themselves.
Benchmarks like CryptoAPI-Bench and CamBench have been developed to evaluate these tools, but they often rely on manually crafted examples. Such benchmarks may not fully capture the complexities and nuances of real-world application code, potentially missing the types of subtle false alarms identified in this research. While some previous efforts involved manual investigation of specific tool alarms or small-scale user studies, this work distinguishes itself by offering a systematic, in-depth technical investigation across multiple state-of-the-art detectors. It reveals a broader and more granular range of false alarm patterns, providing concrete and actionable improvement directions that address the precision and usability issues plaguing current cryptographic misuse detection tools.
Key Findings
▶ Watch: Background: False alarms deter developer adoption (4:00)
The research provides compelling empirical evidence that a significant number of alarms generated by academic static cryptographic API misuse detectors are, in fact, false alarms. This challenges previous claims of precision and highlights substantial room for improvement in both detection capabilities and reporting mechanisms. The study categorizes these inaccuracies into two types: False Positives (FPs), which are traditional false alarms due to detector implementation bugs, and Ineffectual True Positives (ITPs), which are technically correct detections of a pattern but are unhelpful to developers because the underlying rule does not reflect a true vulnerability in context.
A core contribution is the identification and distillation of high-level root-cause patterns for these false alarms. These patterns fall into several categories:
- Implementation Bugs: Flaws within the detector's static analysis engine, such as broken data flow analysis or incorrect string matching.
- Imprecise Modeling: Issues where the detector's rules or models fail to accurately capture the nuances of cryptographic API usage, leading to unresolved polymorphism or overly conservative thresholds.
- Overly Conservative Rules: Misuse rules that are too broad and flag legitimate, non-vulnerable uses of APIs, such as prohibiting all uses of AES-ECB or non-cryptographically secure pseudo-random number generators (CSPRNGs) regardless of context.
- Overlooked Standard Mandates: Failure to account for instances where protocol standards mandate the use of algorithms or modes generally perceived as weak, leading to alarms for standard-compliant code that developers cannot unilaterally change.
The study also demonstrates the generalizability of these false alarm patterns and proposed improvement directions across different types of detectors. This includes an investigation into SpotBugs, a popular open-source industry static detector, and Crylogger, an academic dynamic detector, confirming that similar issues plague a broader range of security analysis tools. Finally, to facilitate future research and enable reproducibility, the authors have publicly released artifacts, including minimal working examples (MWEs) illustrating the problems and refined versions of the detectors. This provides a valuable resource for the security research community to build upon.
Technical Deep Dive
▶ Watch: Methodology: FPs vs. Ineffectual True Positives (6:00)
The methodology employed in this research was a two-phase approach designed to systematically identify and analyze false alarms. The study defined two distinct types of false alarms: False Positives (FPs), which are traditional errors caused by bugs or limitations in the detector's static analysis implementation, and Ineffectual True Positives (ITPs), which represent technically correct detections of a pattern that are ultimately unhelpful or misleading to developers because the underlying misuse rule or model does not accurately reflect a true vulnerability or actionable issue in the given context.
For the analysis, two distinct datasets were used. For Java-targeting detectors, CryptoGuard and CogniCryptSAST, the researchers analyzed 3,489 open-source Android applications collected from F-Droid, chosen for its provision of non-obfuscated source code. For CryptoREX, which targets binaries, 1,177 firmware images from six vendors were downloaded. Specific commit IDs for each detector were used to ensure reproducibility: CryptoGuard (92551ee), CogniCryptSAST (1405ebd) with its CrySL rule set (6d844ab), and CryptoREX (3dc81c9).
In the first phase, misuse reports were sampled and manually analyzed. Given the high volume of alarms, reports were merged based on misuse data and relevant code identifiers to identify common patterns, particularly in third-party libraries. The top-10 offending methods or functions were inspected, and alarms likely to be false were specifically targeted. Each identified false positive was distilled into a minimal working example (MWE). In the second phase, for correctable false alarms, the detector models or implementations were refined and re-run on the datasets to estimate the overall spread of these issues.
Before detailing the findings, a brief overview of the detectors' architectures is helpful.
- CryptoGuard 1 targets Java/Android applications, checking 16 rules across five attack types. It employs an on-demand data flow analysis built on the Soot framework, performing flow-, context-, and field-sensitive forward and backward slicing to trace def-use relations and identify specific API parameters.
- CogniCryptSAST 2 also targets Java/Android. Its misuse rules are expressed in CrySL, a domain-specific language, capturing usage patterns for 49 Java classes. It models each CrySL rule as a finite-state machine, integrating IDEat for flow-, field-, and context-sensitive typestate analysis and extending Boomerang for on-demand pointer analysis.
- CryptoREX 3 targets binaries (IoT firmware) with a simpler design, checking six rules, mostly from CryptoLint. It performs backward slicing to detect constant parameters for cryptographic functions and uses
nm -Dto check for PRNG imports likerandandsrand. It relies on angr for its analysis.
The investigation uncovered 19 distinct patterns of false alarms, categorized as follows:
False Positives (FPs) from Static Analysis Implementation Bugs
These FPs are direct results of flaws in the detector's code or underlying analysis engine:
- Pattern #1: Broken def-use chains due to variable reassignment in CryptoGuard. CryptoGuard's backward slicing incorrectly assumes single assignment in the Jimple intermediate representation (IR). For example,
KeyStore.getDefaultType()(returningjks) was erroneously linked as a constant password forKeyStore.load()after a variable reassignment. A refinement to kill variables after their nearest assignment and union variable sets at merge points significantly reduced FPs: 61.63% for rules 1 and 2, 32.42% for rule 3, and a staggering 95.23% for rule 13. - Pattern #2: Incorrect string matching in data flow analysis in CryptoGuard. This involved a bug in a regular expression for matching field names (missing dollar-prefixed variables) and an erroneous
toString().contains()method expanding array variable matching, leading to 23 FPs. - Pattern #3: Incorrect detection of hard-coded arrays due to a bug in CogniCryptSAST. The
isHardCodedArrayfunction in CogniCryptSAST incorrectly returned the right-hand-side (RHS) value of an allocation instead of the left-hand-side (LHS). This caused arrays generated bySecureRandomto be flagged as hard-coded constant passwords, leading to 24HardCodedErrorFPs inKeyStoreand 28 inPBEKeySpec. - Pattern #4: Incorrect handling of call-return edges of CFG in CryptoREX. CryptoREX, built on angr, improperly handled call-return edges, effectively ignoring function calls during backward slicing while capturing their side effects. This led to non-constant return values being reported as constant seeds for
rand(), resulting in 1 FP for rule 3, 28 FPs for rule 4, and 113 FPs for rule 6.
Ineffectual True Positives (ITPs) due to Modeling Issues
These ITPs arise from problems in the misuse rules themselves, often being overly broad or imprecise:
- Pattern #5: Static typing information available but underutilized in CogniCryptSAST. CogniCryptSAST's typestate analysis suffered from unresolved polymorphism. Its Class Hierarchy Analysis (CHA) for call graph construction included all classes implementing an interface, even when the static type was known. This led to
TypestateErrorandIncompleteOperationErrorFPs (at least 34 and 80, respectively). More precise call graph algorithms like Rapid Type Analysis (RTA) or Variable Type Analysis (VTA) were recommended. - Pattern #6: Reasonable iteration counts considered insecure in CogniCryptSAST. CogniCryptSAST's PBE rules required an iteration count of at least 10,000, while the widely accepted lower bound was 1,000. This overly conservative threshold generated 22
ConstraintErrorFPs inPBEKeySpecand 2 inPBEParameterSpec. - Pattern #7: Reasonable key sizes considered insecure in CryptoGuard. CryptoGuard's rule 15 incorrectly demanded EC keys to be at least 512-bit (ED25519 uses 256-bit keys) and flagged Android's acceptable default 256-bit EC keys as insecure. Overall, 53.3% (16 out of 30) of all rule 15 alarms were ITPs.
- Pattern #8: No key-pair generator equals to insecure public key in CryptoGuard. CryptoGuard's slicing mechanism, which takes the final statement in a method as the result, missed crucial context like
NoSuchAlgorithmException. It reported rule 15 violations even when noKeyPairGeneratorobject was created, leading to 8 FPs. - Pattern #9: Constant seeds assumed to always make outputs of SecureRandom predictable in CryptoGuard. Rule 8 flagged any use of constant seeds with
java.security.SecureRandom. However,SecureRandombehavior with constant seeds depends on the platform, API call sequence (e.g.,setSeed()supplementing existing entropy), and PRNG implementation (e.g., Android 4.2+ OpenSSL PRNG). 15 of 81 apps with rule 8 violations had aminSdkVersionof Android 7+, making these definite FPs. - Pattern #10: Narrow whitelist constraints in detecting MITM issues in CryptoGuard. Rules 4-6 checked predefined whitelists for
HostnameVerifier,TrustManager, andSSLSocket, which were too narrow. This led to FPs for legitimate control flow-influencedverify()methods (7 FPs), flawedTrustManagermodels (many ITPs for dummycheckClientTrusted(), 125 FPs forgetAcceptedIssuers()), and unacknowledged alternativeSSLSockethostname verification methods (15 FPs). - Pattern #11: All IVs must come from SecureRandom, even for decryption in CogniCryptSAST. CogniCryptSAST's
RequiredPredicateErrorrules forPBEKeySpec,PBEParameterSpec, andIvParameterSpecrequired IVs/salts to be generated fromSecureRandom. This is impossible for decryption, leading to at least 280 FPs. Similarly, 37 FPs were found for AES-SIV, which uses synthetic IVs. - Pattern #12: Legitimate origins of key materials prohibited in CogniCryptSAST. The
SecretKeySpec.cryslrule was overly restrictive, requiring key bytes to originate from an existingKeyorSecretKeyobject, prohibiting legitimate practices like loading from files,SecureRandomgeneration, or custom library classes (e.g., Google Tink). This resulted in 549RequiredPredicateErrorFPs. - Pattern #13: Whitelist constraints ignore idiosyncrasies of Android in CogniCryptSAST. CogniCryptSAST's JCA-centric rules failed to account for Android API specifics. This included omitting common
AndroidKeyStorenames (96.2% or 331/344KeyStoreerrors were ITPs),TrustManagerFactoryomissions (all 46 errors were ITPs), excludingPKCS7Padding(an alias ofPKCS5Paddingon Android) fromCipherwhitelists (20.9% or 150/716 errors were ITPs), and overly strictSSLContext.getInstance()protocol requirements (92.6% or 1704/1840 errors were ITPs). Additionally, securenullparameters forSSLContext.initandTrustManagerFactory.inittriggeredRequiredPredicateErrorITPs (720 and 1130, respectively). - Pattern #14: Seeding with srandom not allowed in CryptoREX. CryptoREX's rule 6 flagged
srandomas a misuse, despite its functional equivalence tosrand. Correcting this reduced rule 6 violations from 133 to 116.
Ineffectual True Positives (ITPs) due to Usage Contexts
These ITPs arise from overly conservative rules that do not capture sufficient conditions for vulnerabilities:
- Pattern #15: All usage of AES-ECB considered insecure (CryptoGuard, CogniCryptsAST, CryptoREX). All three detectors prohibited any use of AES-ECB, ignoring its legitimate uses as a raw block cipher for implementing other secure modes (e.g., AES-OCB, AES-EAX) or in standards (e.g., BIP38). CryptoGuard flagged 22 (38%) of its 57 AES-ECB alarms as ITPs; CryptoREX reported 140 ITPs out of 566 rule 1 alarms.
- Pattern #16: All usages of non-CSPRNGs considered vulnerabilities (CryptoGuard, CryptoREX). CryptoGuard's rule 9 flagged any use of
java.util.Random, generating 9042 alarms. 2602 cases in the top-10 offending methods were ITPs, as non-CSPRNGs are legitimately used for non-security-critical purposes (UI animations, media players, probabilistic algorithms). CryptoREX's rule 6 had similar issues with 272 FPs forrand()in contexts like cache mechanisms or generating random time intervals. - Pattern #17: All http:// considered vulnerabilities (CryptoGuard). Rule 7 flagged any URL starting with
http://. Many of the 1645 alarms were ITPs involving local loopback addresses, debugging purposes (e.g., React Native DevServerHelper, 122 alarms), or placeholders. Localhost cases alone accounted for 477 (29.0%) alarms. - Pattern #18: All usage of collision-prone hash functions considered vulnerabilities (CryptoGuard). Rule 16 flagged MD5 and SHA-1 as weak, even when used legitimately where collision resistance is not critical (e.g., file hashing in error messages, checksums, lookup indices in local caches). This led to 72 FPs.
Ineffectual True Positives (ITPs) due to Standard Mandates
These ITPs occur when protocol standards mandate algorithms generally perceived as weak:
- Pattern #19: Protocol standards mandate the use of weak algorithms, modes, and constants. Examples include SHA-1 for DNSSEC signers (30 ITPs for CryptoGuard rule 16), AES-ECB/NOPADDING for Adobe PDF permission strings (2 ITPs for CryptoGuard rule 11), PBE with iteration count 1 in Bouncy Castle for old OpenSSL private keys (31 alarms for CryptoGuard rule 13), and specific IVs for 3DES-CBC/AES-CBC in MRTDs (32 ITPs for CryptoGuard rule 12, 6 for CryptoREX rule 2). The Apache HttpClient library's NTLM protocol support also mandated MD5, RC4, and DES-ECB, leading to numerous alarms across CryptoGuard and CryptoREX.
Demo / Proof of Concept
▶ Watch: Datasets used for detector evaluation (6:45)
While the talk highlights the creation of minimal working examples (MWEs) to clearly illustrate the identified false alarm patterns, it does not describe a live demonstration of these MWEs or a specific proof-of-concept exploit. The MWEs serve as concrete, debloated code snippets to aid in the understanding and reproduction of the detector bugs and modeling issues, and are part of the publicly released artifacts.
Defensive Implications
▶ Watch: Two-phase analysis: sampling and root-cause analysis (8:00)
The findings of this research carry significant implications for both developers utilizing cryptographic misuse detectors and researchers designing future tools.
For developers, the primary takeaway is a reinforced caution regarding the output of static analysis tools. The sheer volume of false alarms, both FPs and ITPs, means that reports cannot be blindly trusted as indicators of critical vulnerabilities. Developers should:
- Critically Evaluate Alarms: Understand the context of the reported misuse. Is it in a security-critical path? Is the "weak" algorithm used in a non-security-sensitive context (e.g., hash for data integrity, not collision resistance)?
- Verify Detector Assumptions: Be aware that detectors often make assumptions about "correct" coding practices or the threat model. If an alarm seems questionable, investigate whether the detector's underlying rule aligns with the actual security requirements and platform specifics (e.g., Android API idiosyncrasies).
- Prioritize Actionable Alerts: Focus remediation efforts on alarms that clearly indicate a demonstrable vulnerability under a relevant threat model. Ignoring non-actionable alarms reduces alert fatigue.
- Consult Standards and Recommendations: When an alarm flags a standard-mandated algorithm (e.g., SHA-1 in DNSSEC), understand that developers may not have the autonomy to change such design choices.
For tool developers and researchers, the paper provides a roadmap for building more precise and usable detectors:
- Focus on Sufficient Conditions: Future detectors should move beyond simply flagging "weak" APIs to modeling and targeting the sufficient conditions under which an API misuse truly becomes a vulnerability. This requires more fine-grained API models that consider data flow, control flow, and execution context.
- Incorporate Platform and Context Awareness: Detectors must account for platform-specific behaviors (e.g., Android API versions, default PRNG implementations), API call sequences (e.g.,
setSeed()behavior), and legitimate usage contexts (e.g., AES-ECB as a raw block cipher, non-CSPRNGs for non-cryptographic purposes). - Justify Rule Thresholds: Any adopted lower bounds for parameters like PBE iteration counts or key sizes should be clearly justified by citing relevant standards and recommendations, and optionally include reference documents with alarms.
- Refine Static Analysis Implementations: Address fundamental implementation bugs, such as broken def-use chains, incorrect string matching, or improper handling of control flow graph edges, to reduce traditional false positives.
- Improve Call Graph and Pointer Analysis: Utilize more precise call graph algorithms (e.g., RTA, VTA) and robust pointer analysis to resolve polymorphism and accurately track object values, reducing imprecision in typestate analysis.
- Enhance Usability of Reports: Detectors should aim to output or visualize data flows and predicate propagations to help developers pinpoint the actual root cause, as the reported offending method is often not the true origin of the issue.
- Consider Confidence Labeling: For alarms that are context-dependent or arise from standard mandates, detectors could assign confidence labels (high/low) to guide developer prioritization.
- Collaborate and Validate: Researchers should leverage open-source datasets for evaluation, group offending methods by rule for systematic bug discovery, and consider enlisting independent third parties or contacting developers for feedback.
Ultimately, by addressing the identified patterns of false alarms, future cryptographic misuse detectors can become more trusted, more effective, and genuinely contribute to improving the security posture of software.
Key Takeaways
- High False Alarm Rates Hinder Adoption: Despite advancements, current static cryptographic API misuse detectors suffer from high rates of false positives (FPs) and ineffectual true positives (ITPs), severely impacting developer trust and adoption.
- Root Causes Are Diverse: False alarms stem from a combination of detector implementation bugs (e.g., broken data flow, incorrect string matching), imprecise modeling (e.g., unresolved polymorphism, overly conservative thresholds), legitimate usage contexts being misidentified as vulnerabilities (e.g., AES-ECB for non-encryption, non-CSPRNGs for non-security tasks), and a failure to account for mandated protocol standards.
- Context and Platform Specificity are Crucial: Detectors often fail to consider the nuances of API usage, platform-specific behaviors (e.g., Android API idiosyncrasies), and the actual threat model, leading to flagging acceptable code as insecure.
- Focus on Sufficient Conditions: Future detectors must evolve to model and target the sufficient conditions for a vulnerability, rather than simply flagging "weak" API patterns, to generate more actionable and precise alerts.
- Improved Tooling and Reporting: Significant improvements are needed in static analysis engine implementations, call graph precision, and the usability of reported alarms, including visualizing data flows and providing context-aware confidence labels.
- Generalizability of Findings: The identified false alarm patterns and proposed improvement directions are applicable across various static and dynamic security analysis tools, highlighting a systemic issue in the field.
About the Speaker(s)
Yikang Chen is a researcher whose work focuses on the critical area of cryptographic API misuse detection. This paper, "Towards Precise Reporting of Cryptographic Misuses," presented at the NDSS Symposium, reflects his commitment to improving the practical utility and precision of static analysis tools in software security. His research contributes significantly to understanding the challenges faced by developers when using these tools and proposes concrete, actionable directions for enhancing their effectiveness.
All talks from Network and Distributed System Security (NDSS) Symposium 2024