Hammurabi: A Framework for Pluggable, Logic-Based X.509 Certificate Validation Policies

James Larisch, Waqar Aqeel, Michael Lum, Yaelle Goldschlag, Leah Kannan, Kasra Torshizi, Yujie Wang, Taejoong Chung, Dave Levin, Bruce M. Maggs, Alan Mislove, Bryan Parno, Christo WilsonCCS 2022

Introduction

The security of the modern web relies heavily on the Public-Key Infrastructure (PKI) and X.509 certificates. Browsers use these certificates to establish trust with web servers. However, validating these certificates is an incredibly complex task, governed by a myriad of RFC standards and "Baseline Requirements." Currently, this validation logic is "entangled"—hard-coded into thousands of lines of C or C++ within browser engines and TLS libraries. This entanglement creates significant hurdles for auditing, code reuse, and cross-browser comparison. When browsers disagree on a certificate's validity, identifying the root cause is often a manual, error-prone process.

System Architecture

To address these challenges, we present Hammurabi, a framework that decouples certificate validation policy from its underlying mechanism. Hammurabi splits the validation process into two distinct components: a high-performance engine and a declarative policy.

The Hammurabi Engine architecture, illustrating the separation of policy and mechanism.

The Engine (Mechanism), implemented in Rust, handles the computationally intensive tasks of parsing certificate fields, verifying cryptographic signatures, and retrieving revocation data via OCSP or CRLs. It transforms these raw data points into a set of logical "facts."

The Policy (Logic) is written in Prolog. Instead of procedural code, policy authors define the logical constraints that a certificate must satisfy to be considered valid. This approach allows for a drastic reduction in complexity; for instance, the researchers reduced approximately 5,000 lines of C++ browser logic into fewer than 650 lines of declarative Prolog.

Logic-Based Validation

By representing certificate attributes as Prolog facts, Hammurabi enables a more rigorous and auditable validation process. The engine produces facts covering X.509 fields, environment variables (like the current time and hostname), and revocation status.

Examples of X.509 facts generated by the engine for Prolog evaluation.

A key advantage of using a logic programming language is imputation. Because Prolog can work "backwards," researchers can use the system to automatically generate certificates that meet specific criteria. This capability allows for the automated discovery of policy discrepancies between different browser implementations (e.g., "Find a certificate that Chrome rejects but Firefox accepts").

Evaluation and Results

Hammurabi was evaluated using a massive dataset of 10 million real-world certificates from public Certificate Transparency logs and 100,000 synthetic "Frankencerts" designed to test edge cases.

The results demonstrate that Hammurabi achieves high fidelity, matching the validation decisions of Chrome and Firefox on 100% of the 10 million real-world certificates. Furthermore, despite the overhead of a logic-based approach, Hammurabi's performance is competitive, with a median logic execution time of approximately 2ms.

The most significant finding was the discovery of 9 subtle discrepancies between Chrome and Firefox. These included differences in handling wildcard certificates (e.g., *.co.uk), certificate lifetimes, and legacy "Common Name" fallbacks. These differences were found automatically through imputation, a feat that would be nearly impossible with traditional procedural code.

Conclusion

Hammurabi demonstrates that logic-based certificate validation is not only feasible but superior for security-critical infrastructure. By separating policy from mechanism, we can create more auditable, reusable, and consistent validation systems. Looking forward, the adoption of executable Prolog policies by standards bodies could eliminate the ambiguities inherent in text-based RFCs, ensuring a more secure and predictable web PKI.

Summary updated

BibTeX
@inproceedings{larisch2022hammurabi,
  author = {James Larisch and Waqar Aqeel and Michael Lum and Yaelle Goldschlag and Leah Kannan and Kasra Torshizi and Yujie Wang and Taejoong Chung and Dave Levin and Bruce M. Maggs and Alan Mislove and Bryan Parno and Christo Wilson},
  title = {{Hammurabi: A Framework for Pluggable, Logic-Based X.509 Certificate Validation Policies}},
  booktitle = {CCS},
  year = {2022},
  doi = {10.1145/3548606.3560594},
}
Figure