Trail of Bits Blog Note

Trail of Bits Blog

blog.trailofbits.com is the official blog of Trail of Bits, a cybersecurity company that provides a range of services including penetration testing, secure coding, and software security assessments. The blog appears to be focused on sharing knowledge and insights related to cybersecurity, with articles and posts covering a variety of topics such as software security, threat modeling, vulnerability analysis, and secure coding practices. The website is clean and simple in design, with a straightforward layout that makes it easy to navigate and find specific articles or topics of interest. There is a search function available on the website, allowing users to quickly find specific articles or topics. Additionally, articles are categorized by topic, making it easy to browse through related content. The blog also features guest posts from experts in the field of cybersecurity, adding to the diversity of perspectives and insights shared on the site. Overall, the Trail of Bits blog appears to be a valuable resource for individuals interested in learning more about cybersecurity and staying up-to-date on the latest developments and trends in the field.

Thread Of Notes

Researchers discovered that some RSA private keys have bits heavily biased toward 0, which can be detected and factored quickly. Along with Hanno Böck of the badkeys project, they found hundreds of unique keys with this property and analyzed historical data to track the issue over time. The pattern of 0 bits in these keys is often highly structured, allowing for the development of a polynomial-based cryptanalytic technique to exploit the pattern. The researchers identified two patterns of RSA moduli with repeated blocks of 0 bits, with one pattern remaining unexplained and the other traced to a type mismatch in big-integer code from old versions of the CompleteFTP file transfer software. The CompleteFTP bug also generated vulnerable short-sleeve DSA keys, and the researchers recovered 603 unique RSA private keys and 74 DSA keys from internet scans. The badkeys project is an open-source service that checks public keys for known vulnerabilities, and by searching a dataset of real-world keys, the researchers uncovered a large number of keys in the wild with the patterns. The researchers reverse-engineered the CompleteFTP vulnerability and found that it was caused by a mismatch between the size of the limbs and the size of the RNG output. The vulnerability was contained after the CompleteFTP team released an update that automatically checks for vulnerable keys and alerts the user if the key needs to be regenerated. The researchers also developed a technique for factoring integers by representing them as polynomials, which can be used to factor general RSA moduli. The discovery of these vulnerabilities highlights the importance of practical research and the need for continued monitoring of cryptographic implementations to identify and address potential weaknesses.
CdXz5zHNQW_iFKnuRveAb.webp
Public skill marketplaces are rife with malicious skills designed to steal credentials and data. Security companies have introduced skill scanners to detect these threats before installation, but our testing reveals they are ineffective. We successfully bypassed detection mechanisms in ClawHub, Cisco's agent skill scanner, and multiple scanners integrated into skills.sh. These bypasses were achieved using standard attack techniques and relatively little effort. The static nature of these scanners allows attackers to repeatedly test and refine their methods until they succeed. The security of software supply chains has always been a concern, and the rise of agentic systems has introduced a new vector: skills. Malicious skills can leverage natural language prompts in addition to code, expanding attack possibilities. Skill distribution channels, such as ZIP archives, curated marketplaces, and public marketplaces, have often prioritized speed over security. Public marketplaces, in particular, have become flooded with malicious skills aiming to compromise users' systems. Our analysis of ClawHub's scanner, which uses VirusTotal and a Gemini 3 Flash-based tool, showed it can be bypassed by simply adding excessive newlines to obscure malicious code. Cisco's skill-scanner and the scanners on skills.sh, which handle arbitrary git repositories, were also vulnerable. We exploited this by embedding malicious instructions within .docx files and using poisoned .pyc bytecode, which bypasses both pattern matching and LLM-based analysis. The prompt injection attack on skills.sh disguised malicious commands within seemingly innocuous corporate configuration language. These findings highlight significant vulnerabilities in current skill security measures.
CdXz5zHNQW_sN7fPOqey7.webp
Trailmark is a new open-source library that transforms source code into a queryable call graph. This graph represents functions, classes, and their relationships, along with semantic metadata. Claude skills can directly interact with this graph through a Python API. Traditional security analysis often relies on lists of findings, but attackers think in graphs, creating a disadvantage for defenders. Trailmark aims to provide AI models like Claude with this graph-based reasoning capability. Mutation testing, a method to assess test quality by making small code changes, generates many surviving mutants. A flat list of these mutants doesn't distinguish between equivalent, dead code, or genuinely significant ones. Trailmark enables Claude to triage these mutants based on security relevance, such as reachability from untrusted input. The library processes code in three phases: parsing with tree-sitter for ASTs, indexing into a high-performance graph, and querying for information like callers, callees, and attack surfaces. Trailmark supports seventeen programming languages and offers eight pre-built Claude Code skills. These skills assist in tasks like mutation triage, test vector generation, and protocol diagramming. For instance, the "genotoxic" skill uses graph analysis to classify surviving mutants. Similarly, "vector-forge" generates test vectors to close identified coverage gaps. Trailmark also integrates findings from static analyzers and audit tools, mapping them onto the code graph. Internal use on cryptographic libraries revealed that equivalent mutants often constitute the majority in well-tested code, a detail missed by flat lists. Graph analysis also highlighted architectural bottlenecks, such as a single permutation primitive in libhydrogen that impacts all cryptographic operations. Mutation testing proves valuable for novel constructions lacking standardized test vectors, by identifying where tests fail to constrain code behavior. Across various codebases, common patterns emerged: arithmetic modules have high blast radii, codec parsers are prime fuzzing targets, and property-based testing is often sparse. Ultimately, Trailmark serves as a connective tissue, linking different analysis tools and enabling more targeted security assessments.
WhatsApp's new Private Inference feature aims to integrate end-to-end encryption with AI by processing messages in secure hardware enclaves called Trusted Execution Environments (TEEs). These TEEs, utilizing AMD's SEV-SNP and Nvidia's confidential GPU platforms, are designed to prevent even Meta from accessing plaintext messages. A pre-launch audit identified numerous vulnerabilities, including eight high-severity issues that could have compromised user privacy. These vulnerabilities stemmed from untrusted data loaded after attestation measurement and incorrect verification of security patch levels. For instance, loading environment variables or ACPI tables after the attestation measurement created backdoors for malicious code injection. The system also initially trusted firmware's claimed patch levels rather than verifying them against cryptographic certificates. Furthermore, a lack of freshness guarantees in attestation reports allowed for replay attacks, enabling attackers to impersonate secure servers indefinitely. Meta addressed these issues by implementing strict validation of variables, custom bootloaders, certificate-based patch level verification, and including nonces in attestation reports. The audit emphasizes that TEEs are not a foolproof solution and require meticulous attention to detail during implementation and deployment. Key lessons learned include the importance of measuring all critical data, validating inputs, and conducting thorough negative testing. Physical security and achieving reproducible transparency also present ongoing challenges in TEE deployments. Ultimately, securing TEE-based systems depends on rigorous attention to security at every layer, not just major architectural choices.
Code coverage is a dangerous metric because it measures execution, not verification, potentially hiding untested critical functionality. Mutation testing, which systematically introduces bugs to see if tests catch them, addresses this by flagging untested code. Historically, mutation testing tools were slow and language-specific, hindering adoption, especially in blockchain. Universalmutator, using regex, gained traction but had limitations with multi-line statements and inefficient mutant prioritization. Slither-mutate improved speed through mutant prioritization and a cleaner testing cycle but remained Solidity-specific. The new tools, MuTON and mewt, aim to overcome these challenges. MuTON offers first-class support for TON blockchain languages by utilizing the tree-sitter parser for better language comprehension and handling multi-line statements. Mewt serves as a language-agnostic core, also supporting Solidity, Rust, and Go. Both tools store results in a SQLite database, enabling persistence and flexible filtering. AI agents can now efficiently configure campaigns and triage results using specialized skills. Future development focuses on AI-guided test generation that encodes requirements, not just bug detection. The goal is to equip AI agents with skepticism and demand external validation for robust test suites. Users are encouraged to install MuTON and mewt, contribute to the open-source projects, and watch for new AI skills that will streamline mutation testing. These advancements promise to transform mutation testing into a more routine and effective part of software development.
Two popular AES libraries, aes-js and pyaes, introduce a significant vulnerability by providing a default IV in their CTR mode implementations. This flaw allows for key/IV reuse, leading to potential plaintext recovery and severe security breaches. Trail of Bits identified this issue and decided to publicly address it due to its widespread impact. The article highlights the contrasting responses of software developers to this security problem. The libraries are widely used, impacting numerous JavaScript and Python projects, therefore the bug's reach is considerable. The default IV makes it easy for users to inadvertently create vulnerable encryption schemes. This design choice significantly increases the likelihood of users implementing key/IV reuse, a critical cryptographic error. Moreover, the libraries lack support for modern, authenticated encryption modes like GCM, exacerbating the risks. The article contrasts the maintainer's dismissive response to this issue (yadda yadda yadda) with the detailed response of strongSwan's maintainer. strongSwan, another affected project, was notified privately, and their maintainer swiftly addressed the vulnerability by replacing the existing library and cipher mode with more secure alternatives, demonstrating true craftsmanship. The strongSwan fix involved detailed changes to ensure data security going forward. The contrast between the two responses highlights the difference between careless coding and a commitment to security. The article stresses the importance of responsible software development and the proper handling of security flaws, emphasizing the need for craftsmen over careless developers.
Go's arithmetic operations on standard integer types are silent by default, meaning overflows wrap around without panicking, which can lead to hidden security vulnerabilities. To address this issue, a modified Go compiler called go-panikint has been released, which turns silent integer overflows into explicit panics. Go-panikint was used to find a live integer overflow in the Cosmos SDK's RPC pagination logic, demonstrating its effectiveness in eliminating a major blind spot for fuzzing Go projects. The tool works by injecting additional checks during the compiler's conversion of code into Static Single Assignment form, which trigger a panic with a detailed error message if an overflow occurs at runtime. Go-panikint can also detect integer truncation issues, but this feature is not currently being pursued due to false positives. The tool is easy to use and can be integrated into existing workflows by replacing the official Go compiler. Go-panikint has two filtering mechanisms to handle intentional overflows, including source-location-based filtering and in-code comments. The tool has been validated through a fuzzing campaign against the Cosmos SDK, which discovered an integer overflow vulnerability in the RPC pagination logic. Go-panikint has two main use cases: security research and fuzzing, and continuous deployment and integration. The community is invited to try go-panikint on their own projects and integrate it into their CI pipelines to uncover hidden arithmetic bugs. Overall, go-panikint provides a valuable tool for uncovering security vulnerabilities in Go projects that were previously invisible to dynamic analysis.
Trail of Bits developed constant-time coding support for LLVM 21, providing compiler-level guarantees that protect cryptographic code against branching-related timing attacks, addressing a critical vulnerability where aggressive modern compilers inadvertently introduce data-dependent branches during optimization. The core solution is the __builtin_ct_select intrinsic, which translates into a special LLVM intermediate representation (llvm.ct.select.*) acting as a security barrier, instructing the compiler to preserve the operation's constant-time properties throughout the entire compilation pipeline. Without this intrinsic, carefully crafted constant-time code, such as those used in lookup tables, can be broken by standard compiler optimizations that introduce speculative branching, creating exploitable timing side channels detectable even with minimal cycle variations. This work directly addresses findings from studies like "Breaking Bad," which documented systematic constant-time guarantee failures in numerous production cryptographic libraries caused by compilers. The __builtin_ct_select intrinsic ensures constant-time execution across various architectures—using cmov on x86-64, CSEL on AArch64, and masked arithmetic on platforms lacking constant-time instructions—allowing developers to write portable and secure code. Upstreaming these changes involved extensive community engagement, leading to strong interest from projects like Rust Crypto and PuTTY, who plan to replace complex inline assembly workarounds with these new primitives. Initial benchmarking confirms minimal performance overhead while achieving 100% preservation of constant-time properties across all tested optimization levels, successfully integrating with major cryptographic libraries. Future plans include extending support with additional intrinsics, such as __builtin_ct_expr for forcing entire expressions to evaluate without branches, and enabling adoption in languages like Rust, Swift, and WebAssembly that target LLVM.
CdXz5zHNQW_IE7PHTX85O.png
A recent hack on Balancer v2, resulting in over $100 million in losses, was caused by a long-standing arithmetic rounding error. Initially, such issues were not considered significant threats to blockchain security due to a different threat landscape. However, as easier attack vectors become scarce, sophisticated attackers now target subtle arithmetic edge cases in DeFi protocols. This incident underscores the critical need for comprehensive invariant documentation and rigorous testing to identify and prevent such vulnerabilities. The vulnerability exploited was a rounding direction error in Balancer v2's Composable Stable Pools. Trail of Bits had previously identified similar rounding issues during audits in 2021 and recommended enhanced fuzz testing. At the time, the full exploitable impact of these precision loss issues was difficult to definitively assess. The evolution of the blockchain ecosystem has seen a shift from primarily access control or key compromise hacks to more complex DeFi-specific exploits like oracle manipulation and rounding errors. In 2023, rounding issues led to significant hacks in protocols like Hundred Finance and Sonne Finance, highlighting their growing prevalence. Trail of Bits' own security ratings now classify codebases without robust rounding strategies as "Weak" in arithmetic maturity. To prevent future exploits, DeFi protocols must meticulously document all invariants related to precision loss and rounding direction, going beyond simple rules like "rounding must favor the protocol." This documentation should then inform comprehensive unit, integration, and fuzz testing suites to achieve 100% coverage. Formal verification can further complement fuzzing by providing additional guarantees. The incident emphasizes four key lessons for the DeFi ecosystem: the critical importance of mathematical accuracy, the necessity of maintaining and updating fuzzing suites with current threat intelligence, the design of robust monitoring and alerting systems, and the implementation of secondary controls to mitigate the impact of potential exploits.
CdXz5zHNQW_iUnAPwl9wT.png