Latacora's blog post "How (not) to sign a JSON object" cautions against signing JSON by stringifying it before applying a signature. This approach is vulnerable to attacks that modify whitespace or key ordering, which changes the string representation without altering the JSON's semantic meaning. The correct method involves canonicalizing the JSON object first – transforming it into a standardized, consistent byte representation – before signing. This ensures the signature validates only identical JSON objects, regardless of superficial formatting differences. The post uses examples to demonstrate the vulnerabilities of naive stringification and advocates using established JSON Canonicalization Schemes (JCS) for robust and secure signing.
Mozilla's code signing journey began with a simple, centralized system using a single key and evolved into a complex, multi-layered approach. Initially, all Mozilla software was signed with one key, posing significant security risks. This led to the adoption of per-product keys, offering better isolation. Further advancements included build signing, allowing for verification even before installer creation, and update signing to secure updates delivered through the application. The process also matured through the use of hardware security modules (HSMs) for safer key storage and automated signing infrastructure for increased efficiency. These iterative improvements aimed to enhance security by limiting the impact of compromised keys and streamlining the signing process.
HN commenters generally praised the article for its clarity and detail in explaining a complex technical process. Several appreciated the focus on the practical, real-world challenges and compromises involved, rather than just the theoretical ideal. Some shared their own experiences with code signing, highlighting additional difficulties like the expense and bureaucratic hurdles, particularly for smaller developers. Others pointed out the inherent limitations and potential vulnerabilities of code signing, emphasizing that it's not a silver bullet security solution. A few comments also discussed alternative or supplementary approaches to software security, such as reproducible builds and better sandboxing.
Sigstore aims to solve the problem of software supply chain security by making it easy to sign software artifacts and verify those signatures. It provides free tooling and a public good transparency log, enabling developers to sign releases with short-lived certificates tied to their identities (e.g., GitHub and email). This allows users to easily verify the provenance and integrity of software, ensuring that it hasn't been tampered with and genuinely originates from the claimed source. Sigstore simplifies the complex process of code signing, removing the need for managing long-lived keys and complicated infrastructure. This makes it significantly more practical for developers to secure their software supply chains and builds trust with end users.
Hacker News commenters generally expressed strong support for Sigstore and its mission of improving software supply chain security. Several praised its ease of use and integration with existing tools, noting the significantly lowered barrier to entry for signing releases compared to traditional methods. Some highlighted the importance of key transparency and the clever use of OpenID Connect for identity verification. A few commenters discussed the potential impact on various ecosystems like Debian and Python, expressing hope for wider adoption and speculating on the future development of the project. Concerns were raised about the reliance on centralized services and potential single points of failure, but these were often met with counter-arguments about the federated nature of OpenID and the transparency of the log. Some users questioned the long-term viability of free certificate issuance, and others debated the nuances of different signing models and their relative security implications.
Summary of Comments ( 0 )
https://news.ycombinator.com/item?id=42990948
HN commenters largely agree with the author's points about the complexities and pitfalls of signing JSON objects. Several highlighted the importance of canonicalization before signing, with some mentioning specific libraries like JWS and json-canonicalize to ensure consistent formatting. The discussion also touches upon alternatives like JWT (JSON Web Tokens) and COSE (CBOR Object Signing and Encryption) as potentially better solutions, particularly JWT for its ease of use in web contexts. Some commenters delve into the nuances of JSON's flexibility, which can make secure signing difficult, such as varying key order and whitespace handling. A few also caution against rolling your own cryptographic solutions and advocate for using established libraries where possible.
The Hacker News post "How (not) to sign a JSON object (2019)" has generated several comments discussing various aspects of JSON signing and security practices.
Several commenters focus on the importance of canonicalization before signing. One commenter emphasizes that the article's core message boils down to "canonicalize before signing," highlighting how failing to do so can introduce vulnerabilities. They further illustrate the point by referencing Python's
json.dumps
function and how different keyword arguments can lead to different string representations of the same JSON object, ultimately resulting in different signatures. Another commenter points out that using JSON for signing is inherently tricky due to the numerous variations possible in a serialized JSON object. They recommend CBOR (Concise Binary Object Representation) as a more suitable alternative for signing because of its consistent binary representation. This reinforces the idea that using a standardized, unambiguous data format is crucial for secure signing.The discussion also delves into specific vulnerabilities related to different JSON parsing libraries. One commenter mentions that some libraries accept duplicate keys, which can be exploited by attackers. They suggest that "canonicalization is about enforcing a schema and rejecting invalid input," emphasizing that strict validation is essential for preventing such attacks. Another user highlights specific problems with PHP’s
json_decode
function and how it handles duplicate keys, which could further expose systems to security risks if not carefully addressed.Another thread in the comments explores the concept of "deterministic JSON," where commenters discuss the challenges in achieving consistent serialization. One commenter notes the difficulty of creating a truly deterministic JSON representation across different languages due to variations in floating-point representations, character encoding, and key ordering.
Several users shared examples of libraries and tools designed for secure JSON signing, including
json-canonicalize
and various JWS (JSON Web Signature) libraries. These comments offer practical solutions for developers seeking to implement secure signing practices.Finally, there's some discussion around JSON Web Signatures (JWS) and JWT (JSON Web Tokens). One commenter criticizes the use of JWT, arguing that JWS provides more flexibility and is sufficient for most use cases. They imply that JWT adds unnecessary complexity and might encourage less secure practices. Another user reinforces this by suggesting the use of detached signatures, emphasizing that signing only the relevant data minimizes the attack surface.
In summary, the comments on the Hacker News post highlight the critical importance of canonicalization before signing JSON, discuss the challenges and vulnerabilities associated with inconsistent JSON representations, recommend alternative formats like CBOR, and provide practical advice on using tools and libraries designed for secure JSON signing. The discussion also touches upon the nuances of JWS and JWT, suggesting simpler approaches for enhanced security.