FIPS-140 Level 3 encryption is just an API call away
Marko Sluga
Overview
In this insightful talk at CypherCon, Marko Sluga, an NGINX Evangelist at F5 (and formerly of AWS), unveiled a practical and cost-effective approach to achieving FIPS 140-3 Level 3 encryption. The presentation, titled "FIPS-140 Level 3 encryption is just an API call away," addresses a critical security gap: the pervasive use of plaintext communication within internal microservices architectures, even when external connections are secured by TLS. Sluga demonstrates how to leverage NGINX JavaScript (NJS) as an edge-based proxy combined with AWS Key Management Service (KMS) to transparently encrypt sensitive data before it enters the internal network, thereby closing a significant exposure window.

Key moments
- 2:00 Introduction to speaker and FIPS 140-3 problem
- 4:10 The need for internal encryption and compliance drivers
- 5:00 Proposed solution: NGINX, NJS, and AWS KMS HSM
- 8:00 AWS KMS and FIPS 140-3 Level 3 HSMs explained
- 12:00 Cost comparison: KMS vs. Cloud HSM vs. Self-hosted
- 15:00 Live demo: Encrypting sensitive data via KMS
- 18:00 Live demo: Demonstrating network latency impact on performance
- 20:50 Key takeaways: Zero refactoring, FIPS 140, indistinguishable performance
FIPS-140 Level 3 encryption is just an API call away
Speakers: Marko Sluga, NGINX Evangelist, F5
Conference: CypherCon
YouTube: https://www.youtube.com/watch?v=lVfiuhPtHiM
Overview
In this insightful talk at CypherCon, Marko Sluga, an NGINX Evangelist at F5 (and formerly of AWS), unveiled a practical and cost-effective approach to achieving FIPS 140-3 Level 3 encryption. The presentation, titled "FIPS-140 Level 3 encryption is just an API call away," addresses a critical security gap: the pervasive use of plaintext communication within internal microservices architectures, even when external connections are secured by TLS. Sluga demonstrates how to leverage NGINX JavaScript (NJS) as an edge-based proxy combined with AWS Key Management Service (KMS) to transparently encrypt sensitive data before it enters the internal network, thereby closing a significant exposure window.
The core problem, as Sluga articulates, is that while TLS effectively encrypts data in transit over the public internet, once that data reaches a server and is decrypted, it often flows in plaintext across an organization's internal mesh of microservices. This internal plaintext exposure violates numerous compliance standards, including PCI DSS, SEC Rule 17A4, SOX, and HIPAA. Sluga's solution offers a compelling alternative to costly and complex application refactoring or the procurement of expensive on-premises Hardware Security Modules (HSMs), providing high-assurance encryption for sensitive information like credit card numbers and Personally Identifiable Information (PII) at a fraction of the traditional cost and operational burden.
This talk is crucial for developers, security architects, and compliance officers grappling with the challenges of securing sensitive data in modern, distributed environments. By abstracting complex cryptographic operations behind a simple API call to a FIPS 140-3 Level 3 certified service, organizations can achieve robust, compliant encryption with minimal performance impact and maximum operational efficiency. Sluga’s demonstration highlights the feasibility of implementing this high-grade security measure transparently at the network edge, making enterprise-grade encryption accessible and manageable for a wide range of applications.
Background
▶ Watch: Introduction to speaker and FIPS 140-3 problem (2:00)
The landscape of modern application architecture has shifted dramatically towards microservices and API-driven communication. While this paradigm offers agility and scalability, it introduces new security complexities, particularly concerning data in transit. The industry standard for securing data over public networks is TLS (Transport Layer Security), which encrypts communication between a client and a server. However, as Marko Sluga points out, this protection often ceases at the application's ingress point. Once TLS is terminated, the data frequently traverses the internal network, moving between various microservices and backend systems, in plaintext. This creates a significant "exposure window," where sensitive data, such as bank account numbers, credit card details, and PII, becomes vulnerable to interception or compromise within the supposedly trusted internal environment.
The existence of this internal plaintext problem is not merely a theoretical security concern; it carries substantial compliance implications. Regulations and standards like SEC Rule 17A4, PCI DSS (Payment Card Industry Data Security Standard), SOX (Sarbanes-Oxley Act), and HIPAA (Health Insurance Portability and Accountability Act) explicitly mandate the encryption of sensitive data, both at rest and in transit, to mitigate risks and protect consumer information. For organizations processing credit cards, even small e-commerce players, compliance with PCI DSS is non-negotiable. The traditional approach to addressing this often involves extensive refactoring of existing applications to incorporate encryption libraries or the deployment of dedicated Hardware Security Modules (HSMs). However, refactoring can be prohibitively expensive and time-consuming, especially for legacy systems or large-scale microservices deployments. On-premises HSMs, while providing robust security, come with significant capital expenditure, operational overhead, and specialized expertise requirements, making them inaccessible for many organizations.
Sluga’s presentation builds upon the recognition that a more agile, less intrusive, and cost-effective solution is needed to bridge this gap. The goal is to perform field-level encryption at the "edge" – immediately after TLS decryption but before sensitive data is passed to internal services. This approach seeks to provide the necessary internal encryption and compliance adherence without forcing a complete architectural overhaul, leveraging existing network infrastructure components and cloud services to deliver high-assurance cryptography as a transparent, on-demand capability.
Key Findings
▶ Watch: Proposed solution: NGINX, NJS, and AWS KMS HSM (5:00)
Marko Sluga's talk highlights several critical findings that collectively demonstrate a paradigm shift in how organizations can achieve high-assurance, compliant encryption:
- Transparent Edge Encryption with NGINX JavaScript (NJS): A central discovery is the power of NGINX JavaScript (NJS) as an embedded middleware. NJS allows for the execution of custom JavaScript code directly within the NGINX proxy, enabling transparent, per-request field-level encryption without requiring any changes to client-side code or backend applications. This eliminates the need for complex SDK integrations or extensive application refactoring, making it an ideal solution for existing systems.
- Cost-Effective FIPS 140-3 Level 3 Compliance via AWS KMS: The presentation rigorously demonstrates that AWS Key Management Service (KMS), backed by FIPS 140-3 Level 3 Hardware Security Modules (HSMs), provides a highly cost-effective and fully managed solution for enterprise-grade encryption. KMS charges are remarkably low, at approximately 3 cents per 10,000 requests and $1 per month per key. This pricing structure makes high-assurance encryption economically viable for operations of virtually any scale, contrasting sharply with the significant capital and operational expenses associated with traditional HSM deployments.
- Secure Envelope Encryption Mechanism: Sluga emphasizes the robust security model provided by envelope encryption within KMS. In this scheme, the sensitive data is encrypted with a unique, ephemeral data encryption key (DEK), which is itself encrypted by a master key residing securely within the FIPS 140-3 Level 3 certified HSM. The critical finding is that the master key never leaves the KMS service, significantly minimizing the risk of key exposure and maintaining the highest level of cryptographic assurance.
- Indistinguishable Performance at Scale: The talk showcases that the actual cryptographic operations performed by KMS introduce indistinguishable latency, often in the realm of milliseconds or even microseconds, when network latency is minimal. The demo illustrates that performance bottlenecks are primarily dictated by network distance rather than the encryption process itself, making this solution suitable for high-volume transaction processing where speed is paramount.
- Out-of-the-Box Compliance: By utilizing KMS, organizations can achieve compliance with stringent regulatory requirements such as PCI DSS, SEC Rule 17A4, SOX, and HIPAA "out of the box." The FIPS 140-3 Level 3 certification of the underlying HSMs provides an unassailable foundation for regulatory adherence, simplifying audit processes and reducing compliance risk.
These findings collectively present a compelling case for adopting cloud-native, edge-based encryption strategies, offering a pragmatic path to enhanced security and regulatory compliance without the traditional barriers of cost, complexity, and operational burden.
Technical Deep Dive
▶ Watch: Cost comparison: KMS vs. Cloud HSM vs. Self-hosted (12:00)
The technical core of Sluga's solution lies in the synergistic combination of NGINX, NGINX JavaScript (NJS), and AWS Key Management Service (KMS), specifically leveraging its FIPS 140-3 Level 3 certified hardware security modules.
NGINX and NGINX JavaScript (NJS): The Edge Processor
At the frontend, NGINX acts as a reverse proxy, handling incoming TLS connections. The crucial component enabling transparent encryption at the edge is NGINX JavaScript (NJS). NJS is not a separate sidecar or SDK; it's a lightweight JavaScript middleware designed to run directly within the NGINX server. It's purpose-built for per-request processing, meaning it can inspect, modify, and act upon individual HTTP requests and responses. This makes it ideal for field-level encryption, where specific sensitive fields (e.g., a credit card number) need to be identified and processed.
NJS operates in small, byte-sized virtual machines, ensuring minimal overhead. For performance optimization, NJS can cache data encryption keys (DEKs) in memory for a specified duration (e.g., minutes). While caching improves latency to microseconds, reducing the need for a KMS call for every single request, it also introduces a temporary "decryption window" and a larger "blast radius" if the cached key were to be compromised. Developers must balance performance needs with security considerations when configuring key caching policies.
AWS Key Management Service (KMS): The FIPS 140-3 Level 3 Backing
AWS KMS is a fully managed service that simplifies the creation, rotation, and management of cryptographic keys. Its primary appeal for this solution is its backing by FIPS 140-3 Level 3 Hardware Security Modules (HSMs). FIPS 140-3 Level 3 certification signifies that the underlying hardware is tamper-proof – any attempt to physically access or compromise the device results in its self-destruction, ensuring that master keys cannot be extracted. This level of assurance is critical for regulatory compliance and robust security.
KMS offers a simple one-API interface for key operations, abstracting the complexity of managing secure hardware. It supports envelope encryption, a fundamental cryptographic pattern used here:
- Key Generation Request: When NGINX/NJS needs to encrypt sensitive data, it makes an API call to KMS's
GenerateDataKeyfunction, specifying the Customer Master Key (CMK) (also known as a primary or root key) to be used. - DEK Issuance: KMS, using the specified CMK (which never leaves the HSM), generates a unique, ephemeral plaintext Data Encryption Key (DEK) and an encrypted DEK. The plaintext DEK is immediately returned to NJS. The encrypted DEK is also returned, wrapped by the CMK.
- Data Encryption (Frontend): NJS uses the received plaintext DEK to encrypt the sensitive data (e.g., a credit card number) using an algorithm like AES-256.
- Transmission to Backend: NJS then sends the encrypted data along with the encrypted DEK to the backend application. Crucially, the sensitive data is never sent in plaintext internally, and the DEK used for encryption is itself encrypted.
- Key Decryption (Backend): The backend application, upon receiving the encrypted data and encrypted DEK, calls KMS's
Decryptfunction, providing the encrypted DEK. - DEK Decryption and Data Decryption: KMS decrypts the DEK using the CMK (again, without the CMK ever leaving the HSM) and returns the plaintext DEK to the backend. The backend then uses this plaintext DEK to decrypt the sensitive data.
This process ensures that the master key (CMK) always remains secure within the FIPS 140-3 Level 3 HSM, while the ephemeral DEKs handle the actual data encryption and decryption, providing a strong separation of concerns and limiting the blast radius in case of a compromise.
KMS vs. Cloud HSM vs. Self-Hosted HSM: Cost and Control
Sluga also provides a detailed cost-benefit analysis of different HSM options:
- AWS KMS: Offers the lowest cost (3 cents per 10,000 requests, $1 per month per key). It's fully managed, highly available, and FIPS 140-3 Level 3 compliant. The trade-off is that AWS owns the root key that encrypts your CMKs, though these CMKs are stored in FIPS-certified HSMs.
- AWS Cloud HSM: Provides dedicated HSM instances that you rent (approx. $145 per hour). Here, you own and control the root key, meaning AWS has no access to it. It also supports standards like PKCS, JCE, and CNG. Cloud HSM can be used as a custom key store backing for KMS, allowing you to use the KMS API while retaining full ownership of the root key within your dedicated HSM. This significantly increases cost (e.g., over $1000/month for 24/7 availability).
- Self-Hosted HSM: Involves purchasing and managing your own physical HSM devices. While providing ultimate control, the Total Cost of Ownership (TCO) can range from $20,000 to $200,000 over three years, largely due to operational burden, support contracts, and the need to build out high availability and API integrations yourself.
The technical deep dive reveals that KMS offers an optimal balance of security, compliance, and cost-efficiency for most organizations, with options to escalate control (Cloud HSM) if specific regulatory or internal policies demand root key ownership.
Demo / Proof of Concept
▶ Watch: Live demo: Encrypting sensitive data via KMS (15:00)
Marko Sluga's presentation included a compelling live demonstration of the proposed solution, showcasing its practical implementation and real-world performance characteristics. The demo utilized both an EC2 instance on AWS (located in US East 1, North Virginia) and a local containerized version of the application, allowing for a comparison of network latency impacts.
The core of the demonstration involved a simple web application where a user could enter a credit card number. To emphasize the live, unscripted nature of the demo, Sluga engaged the audience, asking them to shout out the last four digits of a credit card number, which he then manually entered (e.g., "1234" and later "1268"). This credit card number, along with other simulated details, served as the sensitive data requiring encryption.
The demonstration flow proceeded as follows:
- User Input: The user enters a credit card number into the web application, which is fronted by NGINX.
- NGINX Interception: NGINX, with its embedded NJS module, intercepts the incoming request.
- KMS API Call (Encryption): The NJS code makes an API call to AWS KMS in the US East 1 region. It requests a new data encryption key (DEK) using a specified Customer Master Key (CMK), identified by its unique key ID (e.g.,
arn:aws:kms:us-east-1:...). - Data Encryption: KMS returns both a plaintext DEK and an encrypted DEK. NJS immediately uses the plaintext DEK to encrypt the sensitive credit card number. The encryption algorithm used is AES-256.
- Backend Transmission: NGINX then forwards the encrypted credit card number along with the encrypted DEK to the backend application. The original plaintext credit card number never leaves the NGINX proxy unencrypted.
- Backend KMS API Call (Decryption): The backend application receives the encrypted data and the encrypted DEK. To decrypt the sensitive data, it makes a separate API call to KMS, requesting the decryption of the encrypted DEK.
- Data Decryption: KMS decrypts the DEK using the CMK (which remains securely within the FIPS 140-3 Level 3 HSM) and returns the plaintext DEK to the backend. The backend then uses this plaintext DEK to decrypt the credit card number.
- Result Display: The web application displays both the original (decrypted) credit card number and the corresponding encrypted data, confirming the successful round-trip encryption and decryption.
A key highlight of the demo was the performance analysis. For requests originating from the EC2 instance (co-located with KMS in US East 1), the total encryption time (including the KMS API call) was a mere 32 milliseconds. The subsequent decryption also took 31 milliseconds. This demonstrated the "indistinguishable latency" of the cryptographic operations themselves. In stark contrast, when Sluga performed the same operation from his local machine using a mobile phone's slow network connection, the encryption time soared to over 1,000 milliseconds (1 second). This vividly illustrated that the primary performance factor is network latency, not the cryptographic processing power of KMS.
Sluga further emphasized the security by showing that each encryption request generated a different, unique data encryption key (DEK), even for the same credit card number, as evidenced by the distinct key fingerprints (e.g., VK3A vs B5RYW). This ensures forward secrecy and limits the impact of a single DEK compromise.
The entire codebase for the demo, including the NJS encryption logic (approximately 400 lines of code), the basic HTML application (200 lines), and supporting scripts, totals around 16 kilobytes. Sluga made the code available on GitHub (github.com/markosluga/fips140), providing a QR code for attendees to access it, though he humorously acknowledged the irony of sharing QR codes at a security conference. He also included a disclaimer that the demo code is "not meant for production" but offers "good advice" for those looking to implement it.
Defensive Implications
▶ Watch: Key takeaways: Zero refactoring, FIPS 140, indistinguishable performance (20:50)
Marko Sluga's talk provides critical defensive implications for organizations aiming to bolster their security posture and achieve compliance in modern, distributed environments.
- Eliminate Internal Plaintext Exposure: The most significant defensive implication is the ability to eliminate the "exposure window" created by internal plaintext communication. By encrypting sensitive data immediately after TLS termination at the edge (via NGINX/NJS) and before it reaches backend microservices, defenders can prevent lateral movement attacks from compromising sensitive information. Even if an internal service is breached, attackers will only find encrypted data and encrypted data keys, rendering the information useless without access to the KMS service and the appropriate permissions.
- Achieve FIPS 140-3 Level 3 Compliance: Organizations can now readily achieve FIPS 140-3 Level 3 certification for their key management infrastructure. This is crucial for meeting stringent regulatory requirements such as PCI DSS, SEC Rule 17A4, SOX, and HIPAA. The tamper-proof nature of the underlying HSMs in AWS KMS provides a high level of assurance that master keys are secured against physical extraction and manipulation, simplifying compliance audits and reducing legal and financial risks associated with data breaches.
- Reduce Blast Radius with Envelope Encryption: The use of envelope encryption significantly reduces the blast radius in the event of a compromise. Each sensitive data element is encrypted with a unique, ephemeral Data Encryption Key (DEK). If a DEK were to be compromised, only the specific data encrypted with that DEK would be at risk, not the entire dataset or other sensitive information. Furthermore, since the master key (Customer Master Key, CMK) never leaves the FIPS-certified HSM, attackers cannot directly access the ultimate cryptographic root.
- Transparent Implementation and Minimal Refactoring: Defenders can implement this high-grade encryption without forcing extensive and costly application refactoring. NGINX, acting as a transparent proxy with NJS, intercepts and processes requests at the network edge. This allows security enhancements to be deployed rapidly and with minimal disruption to existing application logic, making it an attractive option for both new and legacy systems. This "zero front-end refactoring" approach accelerates time-to-compliance and time-to-security.
- Cost-Effective High-Assurance Security: The solution offers cost-effective access to FIPS 140-3 Level 3 encryption. By leveraging AWS KMS, organizations can pay mere cents per 10,000 requests, dramatically reducing the capital expenditure and operational burden associated with purchasing, deploying, and managing on-premises HSMs. This democratizes access to advanced cryptographic capabilities, allowing more organizations to implement strong security measures.
- Centralized Key Management: KMS provides a fully managed and highly available key management solution. Defenders benefit from automated key rotation, secure storage, and robust access controls (via AWS IAM), offloading the complex and error-prone task of cryptographic key lifecycle management to a trusted cloud provider. This frees up security teams to focus on higher-level threat intelligence and incident response.
In summary, this approach empowers defenders to implement a robust, compliant, and operationally efficient strategy for securing sensitive data in transit within their internal environments, effectively closing a critical security gap that traditional perimeter-focused defenses often overlook.
Key Takeaways
- Internal Data Encryption is Paramount: Beyond external TLS, encrypting sensitive data as it traverses internal microservices is crucial for security and compliance, addressing the "plaintext exposure window."
- NGINX NJS Enables Transparent Edge Encryption: NGINX JavaScript (NJS) allows for seamless, per-request field-level encryption at the network edge without requiring application code changes or complex SDKs.
- AWS KMS Offers Cost-Effective FIPS 140-3 Level 3 Compliance: Leveraging AWS KMS, backed by tamper-proof FIPS 140-3 Level 3 HSMs, provides high-assurance, compliant encryption at remarkably low costs (e.g., 3 cents per 10,000 requests).
- Secure Envelope Encryption Protects Master Keys: The envelope encryption model ensures that the master encryption key never leaves the secure HSM, while ephemeral data encryption keys are used for actual data encryption, significantly reducing the blast radius.
- Performance is Network-Dependent: Cryptographic operations with KMS introduce negligible latency (milliseconds to microseconds); overall performance is predominantly influenced by network distance and speed.
- Achieve Compliance Without Refactoring: This solution helps organizations meet stringent compliance requirements (PCI DSS, HIPAA, SOX, SEC Rule 17A4) by transparently securing sensitive data at the edge, avoiding costly and time-consuming application refactoring.
About the Speaker(s)
Marko Sluga is an NGINX Evangelist at F5, a role he recently started less than two weeks prior to giving this talk. Before joining F5, Sluga spent approximately four and a half years at AWS (Amazon Web Services). During his tenure at AWS, he initially served as an instructor, sharing his expertise, and later transitioned into a delivery lead role, focusing on enterprise skills transformation. His extensive experience with AWS, particularly in areas related to cloud services and enterprise solutions, provides a strong foundation for his insights into leveraging AWS as a backend for advanced security functionalities like FIPS 140-3 encryption. His background highlights a deep understanding of cloud architecture, security, and the practical challenges faced by enterprises in adopting new technologies.
Reviews
Dr. Zero (Offensive Security Researcher) — SOLID
Sluga shows off using NGINX JavaScript to handle envelope encryption with AWS KMS before passing traffic to internal services. It's a competent implementation of a standard architectural pattern, but pitching an API call to a cloud KMS as a magic bullet for PCI-DSS compliance is vendor theater.
Heather Calloway (CISO) — SOLID
A highly practical architectural pattern for solving the internal plaintext problem that plagues PCI and HIPAA audits. By shifting field-level encryption to the NGINX edge via AWS KMS, organizations can bypass the massive cost of application refactoring and on-prem HSMs.