<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Richard Fan</title>
    <description>The latest articles on Forem by Richard Fan (@richardfan1126).</description>
    <link>https://forem.com/richardfan1126</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F500520%2F0400143e-d07a-4ffb-8755-07ae024b6cbd.jpeg</url>
      <title>Forem: Richard Fan</title>
      <link>https://forem.com/richardfan1126</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/richardfan1126"/>
    <language>en</language>
    <item>
      <title>What You See is What You Get - Building a Verifiable Enclave Image</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Sun, 03 Mar 2024 10:30:06 +0000</pubDate>
      <link>https://forem.com/aws-builders/what-you-see-is-what-you-get-building-a-verifiable-enclave-image-36j0</link>
      <guid>https://forem.com/aws-builders/what-you-see-is-what-you-get-building-a-verifiable-enclave-image-36j0</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Obstacle of proofing TEE&lt;br&gt;
       1.1. Image digest is meaningless&lt;br&gt;
       1.2. Stable image digest is difficult&lt;br&gt;
 2. Solution - Trusted build pipeline&lt;br&gt;
       2.3. GitHub provides the service suite we need&lt;br&gt;
       2.4. Use SigStore to sign and endorse the image&lt;br&gt;
       2.5. Putting everything together&lt;br&gt;
       2.6. How can service consumers verify the PCRs&lt;br&gt;
 3. What's beyond&lt;br&gt;
       3.7. Build log retention&lt;br&gt;
       3.8. Build pipeline still needs to be simple&lt;br&gt;
 4. Wrap up&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Link to the GitHub Action discussed in this post&lt;/strong&gt;: &lt;a href="https://github.com/marketplace/actions/aws-nitro-enclaves-eif-build-action"&gt;https://github.com/marketplace/actions/aws-nitro-enclaves-eif-build-action&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;AWS Nitro Enclaves is a Trusted Execution Environment (TEE) where service consumers can validate if the environment is running what it claims to be running.&lt;/p&gt;

&lt;p&gt;I've posted previously on how to achieve it by using attestation documents and why should we care about the content of the attestation document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.richardfan.xyz/2020/11/22/how-to-use-aws-nitro-enclaves-attestation-documenta.html"&gt;How to Use AWS Nitro Enclaves Attestation Document&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.richardfan.xyz/2022/12/22/aws-nitro-enclaves-ecosystem-1-chain-of-trust.html"&gt;AWS Nitro Enclaves Ecosystem (1) - Chain of trust&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this blog post, I want to dive deep into achieving zero-trust between service providers and consumers on TEE, particularly AWS Nitro Enclaves.&lt;/p&gt;
&lt;h2&gt;
  
  
  Obstacle of proofing TEE
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Image digest is meaningless
&lt;/h3&gt;

&lt;p&gt;Platform configuration registers (PCRs) are just the application image digests; they are generated by a one-way hashing function against the image.&lt;/p&gt;

&lt;p&gt;We cannot see what is inside the image by looking at the hash value. So &lt;strong&gt;without knowing what generated the PCRs, it's meaningless&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For service consumers who have no oversight of the application source code and build process, they have nothing to do, even if they can validate the attestation document. They can only trust whoever saying &lt;strong&gt;"This PCR value 'abcdef' is generated by a secure and safe application"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Service providers may ask 3rd party auditor to attest the above statement. But it's no different than getting SOC2 or ISO 27001 certified.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If we are satisfied with this level of trust model, we can stop talking about TEE already. Why don't we send the SOC2 certificate to the consumers instead of the attestation document?&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Stable image digest is difficult
&lt;/h3&gt;

&lt;p&gt;If service consumers can access the application source code and the build pipeline definition, they may build the enclave image and compare the digest with the one provided in the attestation document.&lt;/p&gt;

&lt;p&gt;The problem is that generating a stable image digest is difficult, &lt;strong&gt;even a small trivial difference occurs in build time can make the digest entirely different&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hX8bDAJK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/d6ecba66-0607-4d84-b9f2-405005ced8e0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hX8bDAJK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/d6ecba66-0607-4d84-b9f2-405005ced8e0.jpg" alt="Build time difference can make the PCR value different" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some common trivial changes in build time are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Timestamp&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some build steps inject the current timestamp into the environment (e.g. &lt;a href="https://github.com/pypa/pip/issues/5648#issuecomment-410446975"&gt;embedded timestamp in &lt;code&gt;.pyc&lt;/code&gt; files when installing Python dependencies&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;This makes the resulting image dependent on the time of build.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;External dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Even if we pin all dependencies to the exact version, using external sources may still cause image differences.&lt;/p&gt;

&lt;p&gt;E.g., when running &lt;code&gt;apt update&lt;/code&gt; on Ubuntu, the manifest pulled from an external source may be different than previously pulled.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Other build time randomness&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are more examples that can cause image differences.&lt;/p&gt;

&lt;p&gt;E.g., Using random strings as temporary folder names.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By looking at the image digest difference, &lt;strong&gt;we cannot tell if it's caused by trivial differences or service provider changing their source code&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution - Trusted build pipeline
&lt;/h2&gt;

&lt;p&gt;To avoid the hiccup of creating a reproducible build process, we can instead &lt;strong&gt;create a trust build pipeline that service consumers can see and trust&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To make it work on AWS Nitro Enclaves images, I have created a GitHub action &lt;a href="https://github.com/marketplace/actions/aws-nitro-enclaves-eif-build-action"&gt;AWS Nitro Enclaves EIF Build Action&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.richardfan.xyz/assets/images/8734c91a-5130-4590-88b7-b93684affa4a.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DPpayyG2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8734c91a-5130-4590-88b7-b93684affa4a.jpg" alt="Using GitHub and SigStore to achieve trusted build pipeline" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  GitHub provides the service suite we need
&lt;/h3&gt;

&lt;p&gt;To achieve an end-to-end chain of trust from source code, build process, to the resulting enclave image, we need a publicly accessible and trusted code repository, build environment, and artifact store.&lt;/p&gt;

&lt;p&gt;Undoubtedly, GitHub is currently the most popular platform to host open-source code. GitHub also provides GitHub Actions as the build environment and GitHub Packages as the artifact store.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By putting the entire build pipeline into GitHub, we can minimize the number of parties we build trust into.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Use SigStore to sign and endorse the image
&lt;/h3&gt;

&lt;p&gt;The other main component of the solution is SigStore.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sigstore.dev/"&gt;SigStore&lt;/a&gt; is a set of open-source technologies to handle the digital signing of software.&lt;/p&gt;

&lt;p&gt;Using SigStore, we can easily sign the enclave image and prove to the public that this image is built by a specific pipeline run, from a particular code repository commit.&lt;/p&gt;
&lt;h3&gt;
  
  
  Putting everything together
&lt;/h3&gt;

&lt;p&gt;In this &lt;a href="https://github.com/richardfan1126/nitro-enclaves-cosign-sandbox"&gt;sample repository&lt;/a&gt;, I use the &lt;strong&gt;AWS Nitro Enclaves EIF Build Action&lt;/strong&gt; to build a Nitro Enclave image from the source code.&lt;/p&gt;

&lt;p&gt;After the artifacts are built and pushed to the GitHub Container Registry (GHCR), there will be a &lt;code&gt;cosign&lt;/code&gt; command to sign the artifact.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--umezEImZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/c53c4a6b-b2c1-4e3e-aa26-f6b0720cdf36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--umezEImZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/c53c4a6b-b2c1-4e3e-aa26-f6b0720cdf36.png" alt="Use cosign to sign the artifact" width="759" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Several things are happening behind this command:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The OIDC token of the GitHub workflow run is used to request a signing certificate from Fulcio&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The digest of the uploaded artifacts (In this scenario, the Nitro Enclave EIF and its information) is signed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The signature is pushed to the artifact store (i.e., GHCR)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The signing certificate and the artifact signature are recorded in the Rekor transparency log&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  How can service consumers verify the PCRs
&lt;/h3&gt;

&lt;p&gt;Service consumers can audit the code once the artifact is signed and pushed to the registry.&lt;/p&gt;

&lt;p&gt;To verify the PCRs they get from the attestation document are &lt;strong&gt;indeed the same as what was built by the said build pipeline&lt;/strong&gt;, they can do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;code&gt;cosign&lt;/code&gt; to verify the artifact against the signature stored in Rekor&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;cosign verify ghcr.io/username/repo:tag &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--certificate-identity-regexp&lt;/span&gt; https://github.com/&amp;lt;username&amp;gt;/&amp;lt;repo&amp;gt;/ &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--certificate-oidc-issuer&lt;/span&gt; https://token.actions.githubusercontent.com
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fFYRDKO---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/12a8d843-4622-4056-ac48-e728b579ba70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFYRDKO---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/12a8d843-4622-4056-ac48-e728b579ba70.png" alt="Use cosign to verify artifact signature" width="800" height="150"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Validate the information on the signing certificate&lt;/p&gt;

&lt;p&gt;User can search the signing entry on &lt;a href="https://search.sigstore.dev/"&gt;Rekor Search&lt;/a&gt; by its log index&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q0RccZVt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/d3dd1538-bba7-4d7a-8442-68469caad1fd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q0RccZVt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/d3dd1538-bba7-4d7a-8442-68469caad1fd.png" alt="Rekor search" width="712" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h9DOThP9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/c3779cbb-86f3-4aef-92da-4030d0ccaa48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h9DOThP9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/c3779cbb-86f3-4aef-92da-4030d0ccaa48.png" alt="Rekor search" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We should look carefully at the following attributes&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;OIDC Issuer&lt;/strong&gt;: The token must be issued by the trusted build environment.&lt;/p&gt;

&lt;p&gt;(In this example, it must be the GitHub Actions OIDC issuer &lt;code&gt;https://token.actions.githubusercontent.com&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;GitHub Workflow SHA&lt;/strong&gt;: This indicates which particular Git commit the build pipeline run is from.&lt;/p&gt;

&lt;p&gt;This helps us identify from which commit we should look at when auditing the source code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Build Config URI&lt;/strong&gt;: This file defines the build workflow.&lt;/p&gt;

&lt;p&gt;We should also check if the build configuration is safe, just like how we audit the application code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Runner Environment&lt;/strong&gt;: We should also ensure the build was run on GitHub-hosted runners instead of self-hosted ones that cannot be trusted.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Audit the code based on the information on the certificate&lt;/p&gt;

&lt;p&gt;After knowing how the artifact was built, we can go to the specific commit of the code repository to audit the codes.&lt;/p&gt;


&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;Pull the artifact and get the PCRs&lt;/p&gt;

&lt;p&gt;After all the validation, we can use &lt;a href="https://oras.land/"&gt;ORAS&lt;/a&gt; to pull the EIF and its information.&lt;/p&gt;

&lt;p&gt;The PCR values are inside the signed text file; they can be compared with the ones given by the attestation document from the running service.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;oras pull ghcr.io/username/repo:tag@sha256:&amp;lt;digest&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q5Vj4_FE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f25adb11-ac30-4cc4-820e-e7ee75e61cb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q5Vj4_FE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f25adb11-ac30-4cc4-820e-e7ee75e61cb4.png" alt="Use ORAS to pull the artifact" width="800" height="230"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's beyond
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Build log retention
&lt;/h3&gt;

&lt;p&gt;GitHub actions run on public repositories can be viewed by anyone; it gives service consumers &lt;strong&gt;more confidence in the enclave application by looking into how exactly it was built&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, the GitHub action log can only be retained for up to 90 days.&lt;/p&gt;

&lt;p&gt;If the service consumers want utmost scrutiny over the enclave application, service providers may need to rebuild the enclave image every 90 days so that &lt;strong&gt;build logs can be audited at any point in time&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build pipeline still needs to be simple
&lt;/h3&gt;

&lt;p&gt;Although service consumers can audit the build process in this design, it doesn't mean service providers don't need to make their build process simple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The more complex a build pipeline is, the more difficult it can be to understand what's being done under the hood&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;E.g., If the build pipeline pulled source codes from an external source instead of the source code repository; How can we see, from the build log, what the content of those codes is?&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;Three years after AWS announced Nitro Enclaves, the support from AWS is still minimal. &lt;em&gt;(Sidetrack: My &lt;a href="https://github.com/aws/aws-nitro-enclaves-sdk-c/pull/132"&gt;PR&lt;/a&gt; on &lt;code&gt;kmstool&lt;/code&gt; is still pending for review)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There is still little to no discussion on how to utilize Nitro Enclaves to achieve TEE in the real world. I hope the tools I build can at least offer some help to the community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to the GitHub Action&lt;/strong&gt;: &lt;a href="https://github.com/marketplace/actions/aws-nitro-enclaves-eif-build-action"&gt;https://github.com/marketplace/actions/aws-nitro-enclaves-eif-build-action&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>nitroenclaves</category>
      <category>sigstore</category>
      <category>supplychainsecurity</category>
    </item>
    <item>
      <title>What You Need to Know About the NIST Guideline on Differential Privacy</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Thu, 22 Feb 2024 03:30:44 +0000</pubDate>
      <link>https://forem.com/richardfan1126/what-you-need-to-know-about-the-nist-guideline-on-differential-privacy-2mb6</link>
      <guid>https://forem.com/richardfan1126/what-you-need-to-know-about-the-nist-guideline-on-differential-privacy-2mb6</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Highlights&lt;br&gt;
 2. What is the current state of privacy protection&lt;br&gt;
       2.1. Input Privacy vs Output Privacy&lt;br&gt;
       2.2. Current De-identification method doesn't work&lt;br&gt;
 3. What is Differential Privacy&lt;br&gt;
       3.3. Differential Privacy is not an absolute guarantee&lt;br&gt;
       3.4. This is one of the first major guidelines for implementation&lt;br&gt;
 4. Differential Privacy Foundations&lt;br&gt;
       4.5. Epsilon (ε)&lt;br&gt;
       4.6. Privacy Unit&lt;br&gt;
 5. Differential Privacy in practice&lt;br&gt;
       5.7. Privacy Budget to limit privacy loss&lt;br&gt;
       5.8. Adding noise to comply with the privacy budget&lt;br&gt;
 6. Challenges&lt;br&gt;
       6.9. Reduced accuracy and utility&lt;br&gt;
       6.10. Applications are still limited&lt;br&gt;
       6.11. Reduced accuracy amplifying bias&lt;br&gt;
       6.12. Security challenges&lt;br&gt;
 7. Back to the basics, data protection is the paramount to privacy protection&lt;/p&gt;




&lt;p&gt;In December 2023, NIST published its first public draft of NIST SP 800-226 &lt;a href="https://csrc.nist.gov/pubs/sp/800/226/ipd" rel="noopener noreferrer"&gt;Guidelines for Evaluating Differential Privacy Guarantees&lt;/a&gt;, this is a huge milestone of the digital privacy domain.&lt;/p&gt;

&lt;p&gt;In this blog post, I'm going to tell you why and what you need to know from the guideline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Highlights
&lt;/h2&gt;

&lt;p&gt;I'm trying to summarize a sixty-page guideline into one blog post, but it's still too long. So, I'm putting the highlight at the beginning for your convenience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Differential Privacy (DP) is a Statistical measurement of privacy loss&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Epsilon (ε) is an important parameter to measure the privacy loss from a data output&lt;/li&gt;
&lt;li&gt;DP limits total privacy loss by setting thresholds of the ε (i.e., Privacy Budget)&lt;/li&gt;
&lt;li&gt;Defining the Privacy Unit is important. (i.e., do we want to protect the privacy of a person? Or the privacy of a transaction?)&lt;/li&gt;
&lt;li&gt;In practice, we add random noise to the output to meet the expected ε (or Privacy Budget)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Challenges&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applications are still limited to simple models (e.g., Analytic queries, simple ML models and synthetic data)&lt;/li&gt;
&lt;li&gt;The reduced accuracy from added noise impacts complex analytic models a lot&lt;/li&gt;
&lt;li&gt;DP on unstructured data is still very difficult&lt;/li&gt;
&lt;li&gt;Bias is introduced or amplified by DP, mainly from the added noise&lt;/li&gt;
&lt;li&gt;Conventional security models also apply to DP implementation. Privacy vs accuracy is an extra consideration.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Data protection and data minimization are still important fundamentals even though we have DP.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is the current state of privacy protection
&lt;/h2&gt;

&lt;p&gt;To understand the importance of &lt;strong&gt;Differential Privacy (DP)&lt;/strong&gt;, we first need to understand the current privacy protection approaches and some basic concepts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Input Privacy vs Output Privacy
&lt;/h3&gt;

&lt;p&gt;In the past, when people wanted to conduct research on data related to individuals, we used different methods to minimize the exposure of the raw data (e.g., Relying on a trusted 3rd party to curate the data, distributing the data curation process to different parties, etc.) These methods prevent privacy leaks from the raw data &lt;strong&gt;Input&lt;/strong&gt;; we call it &lt;strong&gt;Input Privacy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But in some cases, we may also want to publish the research outputs to the broader audience or even the general public. We also need to ensure that an individual's privacy would not be derived from the result data &lt;strong&gt;Output&lt;/strong&gt;; this is called the &lt;strong&gt;Output Privacy&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Current De-identification method doesn't work
&lt;/h3&gt;

&lt;p&gt;The main problem Differential Privacy wants to address is Output Privacy. It is about preventing individual information from being derived by combining different results and reverse engineering.&lt;/p&gt;

&lt;p&gt;The most common method we have been using for decades is &lt;strong&gt;De-identification&lt;/strong&gt;. We always talk about &lt;strong&gt;Personal Identifiable Information (PII)&lt;/strong&gt;, and try to remove them from raw data before doing data research.&lt;/p&gt;

&lt;p&gt;But this method has been frequently proved vulnerable; some prominent examples include &lt;a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2076397" rel="noopener noreferrer"&gt;The Re-Identification of Governor William Weld's Medical Information&lt;/a&gt; and &lt;a href="https://arxiv.org/pdf/cs/0610105.pdf" rel="noopener noreferrer"&gt;De-anonymization attacks on Netflix Prize Dataset&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clearly, with enough auxiliary data, we can re-construct individual information from data that is supposed to be &lt;em&gt;Anonymized&lt;/em&gt;. From this assumption, &lt;strong&gt;every piece of information about an individual should be considered PII&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Differential Privacy
&lt;/h2&gt;

&lt;p&gt;People have been trying to define what PII is for decades and failed repeatedly. Clearly, we need a more robust framework for measuring how much privacy we're preserving when performing anonymization.&lt;/p&gt;

&lt;p&gt;And Differential Privacy is the framework we need. It is a &lt;strong&gt;Statistical measurement of how much an individual's privacy is lost when exposing the data&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Differential Privacy is not an absolute guarantee
&lt;/h3&gt;

&lt;p&gt;The guideline makes it clear at the very beginning that &lt;strong&gt;&lt;em&gt;Differential privacy does not prevent somebody from making inferences about you.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The word &lt;strong&gt;Differential&lt;/strong&gt; means that the guarantee DP provides is relative to the situation where an individual doesn't participate in the dataset. DP can guarantee one's privacy will not face greater risk by participating in the data, but it &lt;strong&gt;doesn't mean it will have no risk at all&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's consider the following example:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Medical research found that smokers have a higher risk of lung cancer, so their insurance premiums are usually higher than those of other people.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's say a smoker, John, didn't participate in that medical research; the result is probably still the same. So, no matter whether he participates or not, his insurance company can still learn that he has a higher risk of lung cancer and charge him a higher premium.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this example, although medical research makes the insurance company know that John has higher risk of lung cancer. But we can still say DP guarantees John's privacy in the medical research because it &lt;strong&gt;makes no difference to him whether he participates or not&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  This is one of the first major guidelines for implementation
&lt;/h3&gt;

&lt;p&gt;Although Differential Privacy has formally existed for almost 20 years, the NIST SP 800-226 guideline is probably the first guideline published by a major institution covering the considerations when implementing it.&lt;/p&gt;

&lt;p&gt;This is a milestone in bringing DP from R&amp;amp;D into the discussion among practitioners and preparing us for broader adoption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Differential Privacy Foundations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Epsilon (ε)
&lt;/h3&gt;

&lt;p&gt;The formal definition of ε is the following formula:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F3fa3ef79-9c14-4adc-8aa5-fdeba8239f19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F3fa3ef79-9c14-4adc-8aa5-fdeba8239f19.png" alt="Definition of Epsilon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It might be too difficult to understand, but it roughly means &lt;strong&gt;The chance where the datasets with and without an individual would produce different outputs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To understand it, we can assume a very small (or even zero) ε; there is little or no difference whether an individual participates in a research. So, there's less chance people can learn if that individual is or isn't in the dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In theory, smaller ε provide more privacy guarantee but less accuracy&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Privacy Unit
&lt;/h3&gt;

&lt;p&gt;Another concept the guideline calls out is the Privacy Unit.&lt;/p&gt;

&lt;p&gt;DP describes the difference between outputs from datasets with or without an individual, but it doesn't define &lt;strong&gt;what is an individual&lt;/strong&gt;. It can be an individual transaction, or a person.&lt;/p&gt;

&lt;p&gt;Since the common concern of data privacy is always about people. So the guideline suggests we always use &lt;strong&gt;User as the Privacy Unit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This means when we apply DP, we should always measure the ε when &lt;strong&gt;ALL records related to one person&lt;/strong&gt; are presented or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Differential Privacy in practice
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Privacy Budget to limit privacy loss
&lt;/h3&gt;

&lt;p&gt;Having a mathematical measurement of privacy, we can limit privacy exposure more quantitatively.&lt;/p&gt;

&lt;p&gt;ε represents the amount of privacy loss from an output; we can sum the ε from all the outputs published from a dataset to measure the total privacy loss.&lt;/p&gt;

&lt;p&gt;This allows us to limit the privacy loss by &lt;strong&gt;setting an upper bound of the total ε allowed for all published outputs from a dataset&lt;/strong&gt;, or we can call it the &lt;strong&gt;Privacy budget&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding noise to comply with the privacy budget
&lt;/h3&gt;

&lt;p&gt;ε is defined by the difference between outputs from datasets with or without an individual; it depends on how impactful an individual is to the output.&lt;/p&gt;

&lt;p&gt;If an individual record is very &lt;em&gt;special&lt;/em&gt; in the dataset, the ε of one output may already exceed the total privacy budget.&lt;/p&gt;

&lt;p&gt;So, in practice, we'll add random noise into the output to fulfill the ε requirement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding random noise lowers the difference between outputs from datasets with or without an individual, thus lowering the ε&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Reduced accuracy and utility
&lt;/h3&gt;

&lt;p&gt;Accuracy and utility of an output may be related but not necessarily the same.&lt;/p&gt;

&lt;p&gt;The guideline calls it out by stating that output may be accurate but not useful if most attributes are redacted. Output may also be less accurate but still useful if the survey base is large.&lt;/p&gt;

&lt;p&gt;But either way, DP impacts both the accuracy and utility of the outputs. The primary reason is the &lt;strong&gt;added random noise to the outputs&lt;/strong&gt;, especially when the data size is small and more noise is required.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applications are still limited
&lt;/h3&gt;

&lt;p&gt;The guideline lists several applications of Differential Privacy; I would group them into the following 3 categories:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Analytic queries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This category includes most commonly used aggregation queries (e.g., Count, Summation, Min, Max, etc.)&lt;/p&gt;

&lt;p&gt;Because the output of these queries is numbers, it's &lt;strong&gt;easy to measure the privacy loss&lt;/strong&gt; and &lt;strong&gt;add random noise to comply with the privacy budget&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In fact, these queries are the most commonly adopted application of DP and have the most detailed guidelines.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Synthetic data and Machine learning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The guideline puts these 2 into separate categories, but I would group them together to simplify things.&lt;/p&gt;

&lt;p&gt;Generating synthetic data or training ML model from the dataset can &lt;strong&gt;give the curated output more correlation between attributes&lt;/strong&gt; (The guideline uses an example of the type of coffee vs purchases' age), which analytic queries are not good at.&lt;/p&gt;

&lt;p&gt;There are some well-known methods for applying them to DP, like Marginal distributions and Differentially-private stochastic gradient descent (DP-SGD).&lt;/p&gt;

&lt;p&gt;However, they are facing a similar problem: &lt;strong&gt;The accuracy and utility of the output are easily affected by the model's complexity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The main reason is that the random noise added to the DP output will be amplified when the analysis goal becomes more complex (e.g., more dimension on the synthetic data, more complex deep learning model, etc.).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Unstructured data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unstructured data are things like text, pictures, audio, video, etc. These data makes it difficult for people to identify the owner (e.g., a video can contain multiple people's faces)&lt;/p&gt;

&lt;p&gt;The major obstacle to applying DP to these data is &lt;strong&gt;the difficulty of identifying a meaningful privacy unit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Currently, there is very little research on applying DP to unstructured data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Reduced accuracy amplifying bias
&lt;/h3&gt;

&lt;p&gt;The 3 biases introduced or amplified by DP are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Systemic bias&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The smaller a dataset is, the more impact an individual can have on the result.&lt;/p&gt;

&lt;p&gt;That's why when dealing with smaller groups (e.g., minority population), the noise needed for DP is larger than that of others.&lt;/p&gt;

&lt;p&gt;This larger noise can significantly impact the outputs of the already small dataset.&lt;/p&gt;

&lt;p&gt;In some extreme cases, &lt;strong&gt;the noise added to the output can even make a minority group non-existent in a research output&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This would amplify the public bias towards minority populations.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Human Bias&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What DP can make the output even worse than erasing the entire group is that added noise can make unrealistic results.&lt;/p&gt;

&lt;p&gt;E.g.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Random noise can be a fractional number, thus making countable measurements (e.g., population) become fractional&lt;/li&gt;
&lt;li&gt;Random noise can also be larger than the original data (especially when data size and ε are small). Adding negative noise to the output may result in a negative number, which is impossible in measurements like population.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;These unrealistic outputs may affect the public's view towards DP and give them the impression that DP is not a reliable method.&lt;/strong&gt;&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Statistical Bias&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This bias is partly introduced when tackling Human Bias.&lt;/p&gt;

&lt;p&gt;When we post-process the DP output to make unrealistic output realistic, &lt;strong&gt;the overall accuracy and utility may be affected by the change&lt;/strong&gt;.&lt;/p&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;h3&gt;
  
  
  Security challenges
&lt;/h3&gt;

&lt;p&gt;Although the guideline focuses on Differential Privacy, it also reminds us that general security principles also apply to the implementation.&lt;/p&gt;

&lt;p&gt;Some of the guidelines given are similar to conventional risk management, but we'll need to deal with more kinds of vulnerabilities, such as:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Interactive Query&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Allowing data consumers to run their own queries would make DP implementation difficult because data consumers may be untrusted, and they will try to issue &lt;strong&gt;malicious query to break the DP guarantee&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Data custodians also need to store the raw data for real-time queries, which &lt;strong&gt;increases data leak risk&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In my opinion, &lt;strong&gt;this is similar to conventional application protecting the database behind&lt;/strong&gt;. But in DP case, we'll also &lt;strong&gt;take Privacy Budget into account&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Trust Boundary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The guideline explains 2 different threat models: The local model and the Central model.&lt;/p&gt;

&lt;p&gt;Depending on where we put the trust boundary, we will apply DP on different layers, either when &lt;strong&gt;data is sent from data subject to data curator&lt;/strong&gt;, or &lt;strong&gt;from data curator to data consumers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The same principles apply just like when we do the conventional threat model. But in DP case, we also need to balance the output accuracy and risk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The earlier we apply DP, the fewer risks we take. However, the accuracy of the final output also decreases.&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;While some challenges may look similar to conventional security frameworks, some are specific to DP.&lt;/p&gt;

&lt;p&gt;I'm not going to details because they are quite implementation-specific, but the guideline includes the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Floating-Point Arithmetic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Timing Channels&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Backend Issues&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Back to the basics, data protection is the paramount to privacy protection
&lt;/h2&gt;

&lt;p&gt;Last but not least, the guideline closed up by the 2 most fundamental and yet important things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Security and Access Control&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Collection Exposure&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simply put, if we cannot protect the raw data in the first place, all privacy protections would become meaningless.&lt;/p&gt;

&lt;p&gt;And take one more step back, &lt;strong&gt;data protection and privacy protection can minimize but not eliminate privacy risk&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If the data is not needed for research purposes, we shouldn't collect it in the first place.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>differentialprivacy</category>
      <category>privacy</category>
      <category>privacyenhancingtechnologies</category>
      <category>dataprivacy</category>
    </item>
    <item>
      <title>Security Implication of Giving Examples</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Fri, 16 Feb 2024 03:37:27 +0000</pubDate>
      <link>https://forem.com/richardfan1126/security-implication-of-giving-examples-3g4h</link>
      <guid>https://forem.com/richardfan1126/security-implication-of-giving-examples-3g4h</guid>
      <description>&lt;p&gt;In this post, I want to share my thoughts on giving examples in technical writing and the security implications behind it, no matter whether the impact is real or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;We will likely give examples when writing technical documents, formal or informal, from user manuals to personal blog posts.&lt;/p&gt;

&lt;p&gt;And it's inevitable that the examples contain sensitive or even secret values.&lt;/p&gt;

&lt;p&gt;There are many ways we deal with those values (e.g., redacting, modifying, etc.)&lt;/p&gt;

&lt;p&gt;I also have many ways of dealing with them throughout my journey, but I slowly build my own convention.&lt;/p&gt;

&lt;p&gt;And it all started with this &lt;a href="https://www.linkedin.com/posts/richardfan1126_aws-activity-7163779862250373121-iybZ?utm_source=share&amp;amp;utm_medium=member_desktop"&gt;Linkedin post&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;AWS rolled back its managed IAM policy &lt;strong&gt;AmazonEC2ReadOnlyAccess&lt;/strong&gt;, but it turned out it's because &lt;a href="https://www.linkedin.com/in/scott-piper-security/"&gt;Scott Piper&lt;/a&gt;, Principal Cloud Security Researcher at Wiz, mistakenly thought the &lt;strong&gt;ec2:GetPasswordData&lt;/strong&gt; permission allows users to get the EC2 instance password. And it's due to the poor example AWS gives in their &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetPasswordData.html"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But instead of blaming AWS for their poor example, I think I should also formalize my own convention and get feedback from others.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I am confident that we should follow
&lt;/h2&gt;

&lt;p&gt;The following rules are those I'm pretty confident:&lt;/p&gt;

&lt;h3&gt;
  
  
  Do not use mosaic to hide secret
&lt;/h3&gt;

&lt;p&gt;When we want to hide the secrets (i.e., password) on the screenshot, simply redact it with a solid box, &lt;strong&gt;DON'T&lt;/strong&gt; use mosaic.&lt;/p&gt;

&lt;p&gt;There are many techniques and tools available to reveal text under the mosaic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.toolify.ai/ai-news/avoid-this-password-blur-mistake-95545"&gt;https://www.toolify.ai/ai-news/avoid-this-password-blur-mistake-95545&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/HypoX64/DeepMosaics"&gt;https://github.com/HypoX64/DeepMosaics&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't want to reveal your password through your blog post, so just redact it; don't trust the mosaic anymore.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do not show a fake secret
&lt;/h3&gt;

&lt;p&gt;If we want to show the secret on the screenshot or example code, without redacting it.&lt;/p&gt;

&lt;p&gt;Do not make a confusing fake. Make it evident that it's a fake.&lt;/p&gt;

&lt;p&gt;E.g., when we want to give an example of an OAuth token request call&lt;/p&gt;

&lt;p&gt;Instead of using this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://example.com/v1/oauth/token?grant_type=authorization_code
  &amp;amp;code=b87c3c60ca2b54ae
  &amp;amp;client_id=9af83a008718df9b
  &amp;amp;client_secret=af8c86cb8bca211d
  &amp;amp;redirect_uri=https://example.com/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Try using this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://example.com/v1/oauth/token?grant_type=authorization_code
  &amp;amp;code=b87c3c60ca2b54ae
  &amp;amp;client_id=9af83a008718df9b
  &amp;amp;client_secret=&amp;lt;your_client_secret&amp;gt;
  &amp;amp;redirect_uri=https://example.com/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://example.com/v1/oauth/token?grant_type=authorization_code
  &amp;amp;code=b87c3c60ca2b54ae
  &amp;amp;client_id=9af83a008718df9b
  &amp;amp;client_secret=****************
  &amp;amp;redirect_uri=https://example.com/callback
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although all 3 examples do no harm to ourselves because the &lt;code&gt;client_secret&lt;/code&gt; are all fake.&lt;/p&gt;

&lt;p&gt;But the readers with little knowledge of OAuth may not know that &lt;code&gt;client_secret&lt;/code&gt; is something they shouldn't expose.&lt;/p&gt;

&lt;p&gt;And by seeing us showing the secret in the example, they may just follow and show their &lt;strong&gt;REAL&lt;/strong&gt; secret to others.&lt;/p&gt;

&lt;p&gt;The other implication I believe is that, many people &lt;em&gt;(including me)&lt;/em&gt; is generous to inform people when they find something sensitive is posted online &lt;em&gt;(Not just technical stuff, I've DM many people on social media to take down the photos of their boarding pass)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If I message a blog owner to be careful of their secret and get a reply that it's fake. I would feel being fooled and may have less willingness to do the same thing next time, even though it may be the true secret.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I am doing but you may have better options
&lt;/h2&gt;

&lt;p&gt;The following rules are what I am following, but not quite sure if they are the best options.&lt;/p&gt;

&lt;p&gt;You may argue that my reasons are wrong and have better options.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use common pattern for personal values
&lt;/h3&gt;

&lt;p&gt;This is similar to Do not show a fake secret, but for some personal data (e.g. AWS account ID, AWS resource ARN).&lt;/p&gt;

&lt;p&gt;These data are not secrets, but we still don't want to expose them to the public.&lt;/p&gt;

&lt;p&gt;We can use the same method as dealing with secrets, but it may make the example difficult to read.&lt;/p&gt;

&lt;p&gt;So, I would use some common patterns to replace those data.&lt;/p&gt;

&lt;p&gt;E.g., If I were to give an AWS CLI command example of creating an EC2 instance, I can write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 run-instances \
   --image-id &amp;lt;ami_id&amp;gt; \
   --subnet-id &amp;lt;subnet_id&amp;gt; \
   --instance-type &amp;lt;instance_type&amp;gt; \
   --key-name &amp;lt;key_pair_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's still useful, but if I use the following format, it would be more useful because the reader can understand the format of each value and find them more easily.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws ec2 run-instances \
   --image-id ami-11111111111111111 \
   --subnet-id subnet-22222222 \
   --instance-type c5.xlarge \
   --key-name my-key-pair-01
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dealing with encoded values
&lt;/h3&gt;

&lt;p&gt;For encoded or even encrypted values, I still don't have a good option to make the example similar to the real one yet obvious to the reader that it's fake.&lt;/p&gt;

&lt;p&gt;E.g., If I use the same method as dealing with secret values, I may write this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;password_b64: &amp;lt;your_password&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But then the reader doesn't know it's a base64-encode value.&lt;/p&gt;

&lt;p&gt;If I use the base64-encode &lt;code&gt;&amp;lt;your_password&amp;gt;&lt;/code&gt;, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;password_b64: PHlvdXJfcGFzc3dvcmQ+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, the users may not know it's a secret, and they shouldn't expose theirs.&lt;/p&gt;

&lt;p&gt;So right now, what I would write is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;password_b64: &amp;lt;base64_encoded_password&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have more explanatory options, please let me know.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;These are just the rules I found easy for readers to understand yet not making security concerns.&lt;/p&gt;

&lt;p&gt;I see many ways of making examples, even across AWS service teams.&lt;/p&gt;

&lt;p&gt;I really hope we'll have a more standardized way of giving examples (especially when secrets are involved) on technical writing, like the one for &lt;a href="https://www.conventionalcommits.org/en/v1.0.0/"&gt;Git commit message&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Please feel free to share your thoughts.&lt;/p&gt;

</description>
      <category>writing</category>
      <category>writingtips</category>
      <category>technicalwriting</category>
    </item>
    <item>
      <title>When Automation Meets Authentication</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Tue, 06 Feb 2024 16:20:44 +0000</pubDate>
      <link>https://forem.com/richardfan1126/when-automation-meets-authentication-ii2</link>
      <guid>https://forem.com/richardfan1126/when-automation-meets-authentication-ii2</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;This post is not about sharing my success story or lecturing you about some new things. It's more about summarizing my questions about the conflict between automation and authentication.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Recent Trends
&lt;/h3&gt;

&lt;p&gt;Over the past decades, there have been more and more &lt;em&gt;XxxOps&lt;/em&gt;: &lt;strong&gt;DevOps&lt;/strong&gt;, &lt;strong&gt;CloudOps&lt;/strong&gt;, &lt;strong&gt;GitOps&lt;/strong&gt;, &lt;strong&gt;AIOps&lt;/strong&gt;. Recently, I even heard &lt;strong&gt;NoOps&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The common theme of them is to &lt;strong&gt;Automate everything&lt;/strong&gt;. We want people to do as little ops work as possible. We shouldn't even allow people to touch the system in the ideal state.&lt;/p&gt;

&lt;p&gt;But at the same time, we have another trend: everything should be verifiable and traceable, and people should be accountable.&lt;/p&gt;

&lt;p&gt;We are getting rid of shared accounts and long-term credentials. Use MFA and even hardware keys to prevent spoofing.&lt;/p&gt;

&lt;p&gt;But aren't they contradicting? We don't want humans to be involved, but we want humans to be accountable.&lt;/p&gt;

&lt;h3&gt;
  
  
  My recent story
&lt;/h3&gt;

&lt;p&gt;As a cybersecurity practitioner, I'm a fan of hardware keys. I have my own Yubikey, and I use it to sign all my git commits so people can verify my works are done by me.&lt;/p&gt;

&lt;p&gt;As an engineer, I'm also a fan of automation. I often use IaC and CI/CD to help me deploy stuff.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But recently, I'm facing a dilemma.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of my projects is using the IaC repository as the single deployment point. We also use it to deploy application configuration.&lt;/p&gt;

&lt;p&gt;But the question is that there is another repository generating the application configuration.&lt;/p&gt;

&lt;p&gt;So I have these options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Merge two repositories.&lt;/p&gt;

&lt;p&gt;But it will make the repository too big and difficult to maintain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Deploy the configurations separately.&lt;/p&gt;

&lt;p&gt;However, it will make my AWS resources fragmented and difficult to track the state of my environment.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;i.e., No single point of truth on how the current environment state looks like&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Have the application repository generate the configuration and push it to the IaC repository for deployment.&lt;/p&gt;

&lt;p&gt;This one looks pretty reasonable to me. So, I picked this route.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Problems Come
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How do I sign the git commit?
&lt;/h3&gt;

&lt;p&gt;If the app repository is pushing files, it has to make a commit. As a security engineer, I would like to see all the commits in my repository to be signed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Use GitHub's key?
&lt;/h4&gt;

&lt;p&gt;Now you may say, GitHub bot can sign the commit for me.&lt;/p&gt;

&lt;p&gt;But as a security engineer &lt;em&gt;(Or you can say I'm too paranoid)&lt;/em&gt;, I don't trust the GitHub.com GPG key because who knows how many accounts I'm sharing that same key with?&lt;/p&gt;

&lt;h4&gt;
  
  
  Use stored key?
&lt;/h4&gt;

&lt;p&gt;You may also say, I can put the GPG private key into the GitHub Actions and use it to sign the commit. But this is prone to spoofing because people can sniff the key and use it to sign other things.&lt;/p&gt;

&lt;h4&gt;
  
  
  Hardware key?
&lt;/h4&gt;

&lt;p&gt;Hardware keys can prevent private key leaks, but I can't plug my Yubikey into the GitHub data center and use it in my GitHub actions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cloud services?
&lt;/h4&gt;

&lt;p&gt;There are many Cloud HSM/KMS offerings, but I can't find any that provide an easy way to integrate with git.&lt;/p&gt;

&lt;p&gt;I see HashiCorp Vault support acting as a &lt;a href="https://developer.hashicorp.com/vault/docs/enterprise/pkcs11-provider"&gt;PKCS#11 provider&lt;/a&gt; and use it as a hardware key with gpg.&lt;/p&gt;

&lt;p&gt;I also found an &lt;a href="https://github.com/hf/kmspgp"&gt;open-source project&lt;/a&gt; wrapping pgp with AWS KMS.&lt;/p&gt;

&lt;p&gt;But both options look premature to me, and I'm not sure how the security model should look like, so it behaves as similar as an actual hardware key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who can access the IaC repository?
&lt;/h2&gt;

&lt;p&gt;If the app repository workflow wants to push files to the IaC repository, it must have access to it.&lt;/p&gt;

&lt;p&gt;How can I grant it access?&lt;/p&gt;

&lt;h3&gt;
  
  
  Interesting GitHub access model
&lt;/h3&gt;

&lt;p&gt;GitHub Actions supports &lt;a href="https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect"&gt;OIDC authentication&lt;/a&gt;, so we can grant the workflow access over other cloud environments (e.g., AWS account) as the workflow itself. (&lt;strong&gt;Without&lt;/strong&gt; long-term credentials)&lt;/p&gt;

&lt;p&gt;You may think the same should apply to accessing other repositories. Well, the answer is &lt;strong&gt;No&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To programmatically access a GitHub repository, we can use &lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens"&gt;Personal Access Token&lt;/a&gt; or &lt;a href="https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/about-authentication-with-a-github-app"&gt;GitHub App&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Guess what? Both methods involve long-term credentials.&lt;/p&gt;

&lt;p&gt;And unlike OIDC, both methods are not directly tied to the workflow itself.&lt;/p&gt;

&lt;p&gt;I even made a joke with my colleague that GitHub workflow integrates better with other cloud providers than itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitLab is better in this area
&lt;/h3&gt;

&lt;p&gt;GitLab provides two methods for cross-repository workflow.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html#multi-project-pipelines"&gt;Multi-project pipelines&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method allows a pipeline to trigger another pipeline in the other project.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html#add-a-project-to-the-job-token-allowlist"&gt;Job token allowlist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method allows the job token from other projects to access itself.&lt;/p&gt;

&lt;p&gt;So the pipeline from other projects can access it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  This is not unique to GitOps but critical to GitOps
&lt;/h2&gt;

&lt;p&gt;The automation vs authentication issue is not unique to GitOps. There are many companies using automation to sign their software build.&lt;/p&gt;

&lt;p&gt;The reasons I think this issue is more critical for GitOps are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Git commit is the first step of defense&lt;/p&gt;

&lt;p&gt;The first step a code (whether for software or infrastructure) goes to the codebase is when developers commit it.&lt;/p&gt;

&lt;p&gt;No matter how much defense we build around the system. All other defenses are useless if we cannot verify who created the code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The scope is broader&lt;/p&gt;

&lt;p&gt;We may have ten software release pipelines.&lt;/p&gt;

&lt;p&gt;But we may also have thousands of developers committing code and hundreds of workflows around them.&lt;/p&gt;

&lt;p&gt;Managing the keys and validating them is more challenging than other use cases.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Git is everything nowadays&lt;/p&gt;

&lt;p&gt;With the rise of DevOps, IaC, GitOps, etc. We now have more and more kinds of stuff written in code.&lt;/p&gt;

&lt;p&gt;We have application code, configuration, infrastructure, access control list, etc.&lt;/p&gt;

&lt;p&gt;We may face a total system breakdown or takeover if unauthorized code is injected into the repository.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrap up
&lt;/h2&gt;

&lt;p&gt;While I was asking all these questions and doing research. I realized it's not about which method to use, but more about &lt;strong&gt;"Who is the automation"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the differences between 2 GitLab cross-repository workflow methods is that:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-project pipelines&lt;/strong&gt; requires the user triggering the first workflow to have permission on the second repository. And &lt;strong&gt;Job token allowlist&lt;/strong&gt; requires the first repository's job to have permission on the second repository.&lt;/p&gt;

&lt;p&gt;This also triggers me to think: "Is the automation just a representative of the user? Or it has its own identity?"&lt;/p&gt;

&lt;p&gt;Nowadays, we are discouraging shared accounts because we want clear accountability and responsibility. But in the end, automation is still a different form of shared account.&lt;/p&gt;

&lt;p&gt;So, what is the line between a shared account and an automation? I don't have a clear answer.&lt;/p&gt;

&lt;p&gt;What do you think?&lt;/p&gt;

</description>
      <category>gitops</category>
      <category>cloudsecurity</category>
      <category>devops</category>
    </item>
    <item>
      <title>Can We Use aws:SourceVpc Condition Without a VPC Endpoint?</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Thu, 18 Jan 2024 16:18:09 +0000</pubDate>
      <link>https://forem.com/aws-builders/can-we-use-awssourcevpc-condition-without-a-vpc-endpoint-44do</link>
      <guid>https://forem.com/aws-builders/can-we-use-awssourcevpc-condition-without-a-vpc-endpoint-44do</guid>
      <description>&lt;p&gt; 1. Background&lt;br&gt;
 2. Why is VPC Endpoint required?&lt;br&gt;
       2.1. The route of a network request goes within AWS&lt;br&gt;
       2.2. The way IAM knows the API request's context&lt;br&gt;
 3. How AWS documentation fails to make its users understand&lt;br&gt;
       3.1. Does it really mean the source VPC?&lt;br&gt;
 4. Call for action to AWS&lt;/p&gt;
&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Yesterday, I had a discussion with a guy on Slack about "Does IAM &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcevpc" rel="noopener noreferrer"&gt;&lt;code&gt;aws:SourceVpc&lt;/code&gt; condition&lt;/a&gt; requires a VPC endpoint to work?".&lt;/p&gt;

&lt;p&gt;Although the documentation states that &lt;em&gt;This key is included in the request context only if the requester uses a VPC endpoint to make the request&lt;/em&gt;, it's not obvious that a request originated from a VPC doesn't always have the source VPC information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F429bc301-b282-47b9-a94d-01ee7adb55ca.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F429bc301-b282-47b9-a94d-01ee7adb55ca.jpg" alt="The documentation states that VPC endpoint is required, but the story doens't stop here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The documentation states that a VPC endpoint is required, but the story doesn't stop here&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Although the documentation states the pre-requisite of &lt;code&gt;aws:SourceVpc&lt;/code&gt;, there are still some confusion. Luckily, I attended a chalk talk session in last year's AWS re:Inforce about this topic. So, I think it's time to share what I've learned.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F63374aa3-5367-4183-b489-c7d484039f52.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F63374aa3-5367-4183-b489-c7d484039f52.jpg" alt="The Chalk Talk session about IAM that I attended in AWS re:Inforce"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The Chalk Talk session about IAM that I attended in AWS re:Inforce&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why is VPC Endpoint required?
&lt;/h2&gt;

&lt;p&gt;The reason is based on 2 aspects:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The route of a network request goes within AWS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The way IAM knows the API request's context&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  The route of a network request goes within AWS
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F4e17f41a-9536-4c49-b6b7-dc5800ec39cf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F4e17f41a-9536-4c49-b6b7-dc5800ec39cf.jpg" alt="AWS API endpoint is outside the VPC"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;AWS API endpoint is outside the VPC&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Many AWS services can be deployed in a VPC (e.g., EC2 instance, RDS instance, ECS task, Elasticache cluster, etc.)&lt;/p&gt;

&lt;p&gt;For those resources, we can configure the VPC so that the network traffic should route through or entirely within the VPC to reach the resources. For example, a SQL connection from an EC2 instance to an RDS instance within the same VPC (The green line in the above diagram).&lt;/p&gt;

&lt;p&gt;But when it comes to AWS API calls (Let's say an AWS CLI call &lt;code&gt;aws rds stop-db-instance&lt;/code&gt; from the EC2 instance), it cannot stay within the VPC.&lt;/p&gt;

&lt;p&gt;The AWS API call is not going to the resource itself (i.e., &lt;em&gt;The CLI is not talking to the RDS instance "Hey! I want to stop you"&lt;/em&gt;). Instead, the API is going to an AWS API endpoint (&lt;em&gt;in this case, &lt;code&gt;rds.us-east-1.amazonaws.com&lt;/code&gt;&lt;/em&gt;), which is owned by AWS and sits outside of the VPC. (i.e., &lt;em&gt;The CLI is talking to AWS, "Hey! I want to stop that instance, please do it"&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;To reach the AWS API endpoint, the traffic must either go through the AWS backbone network or a VPC endpoint inside the VPC. (The blue line in the above diagram).&lt;/p&gt;

&lt;p&gt;We CANNOT create an AWS API endpoint inside a VPC, so there is no such "AWS API call within a VPC" (The red line in the above diagram doesn't exist)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Correction: The previous version wrongly stated that traffic going out of Internet Gateway to the AWS API endpoint is through the public Internet. But in fact, it is routed through the AWS backbone network.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;However, this change doesn't affect the conclusion of this blog post.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  The way IAM knows the API request's context
&lt;/h3&gt;

&lt;p&gt;AWS IAM policy allows us to define permission based on different criteria, like &lt;em&gt;"Who is making the request?"&lt;/em&gt;, &lt;em&gt;"Where is the request coming from?"&lt;/em&gt;, &lt;em&gt;"How is the requester authenticated in the first place?"&lt;/em&gt;, etc.&lt;/p&gt;

&lt;p&gt;But AWS IAM service doesn't magically know all these contexts on every API request; it relies on the context attached to the request to perform IAM policy evaluation.&lt;/p&gt;

&lt;p&gt;Those contexts are not attached in one place. It depends on what the context is.&lt;/p&gt;

&lt;p&gt;For example, the &lt;code&gt;aws:MultiFactorAuthPresent&lt;/code&gt; is added inside the session token because when we sign in, the STS service knows if we have MFA authentication and injects this information into the session token.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;aws:SourceIp&lt;/code&gt; is added when the request reaches the API endpoint because the endpoint can inspect the IP header and determine which IP the request is coming from.&lt;/p&gt;

&lt;p&gt;We cannot expect the API endpoint to add the &lt;code&gt;aws:MultiFactorAuthPresent&lt;/code&gt; because it doesn't know how the user login in the first place. We also cannot expect the STS service to add &lt;code&gt;aws:SourceIp&lt;/code&gt; into the session token because it won't know where it will be copied and used to sign subsequent API requests.&lt;/p&gt;

&lt;p&gt;So, let's come back to the &lt;code&gt;aws:SourceVpc&lt;/code&gt; context. Who should add this to the request?&lt;/p&gt;

&lt;p&gt;Can the EC2 instance do it? It seems possible because AWS knows where the EC2 instance sits. But is it trustworthy? What if the user generates the API request in the EC2 instance, copies it into the laptop, and sends it through the Internet? Should AWS still treat it as "Coming from the VPC"? It seems not feasible.&lt;/p&gt;

&lt;p&gt;Can Internet Gateway add this context? But the API request is inside an HTTPS request; how can Internet Gateway decrypt it, add the context, and then re-encrypt it? This is also not feasible.&lt;/p&gt;

&lt;p&gt;Can the AWS API endpoint check if the request comes from the EC2 instance's public IP? It seems possible, but keeping track of all public IP addresses is a considerable overhead and would cause performance issues. So this is also not feasible.&lt;/p&gt;

&lt;p&gt;So, the only possible way to do it is to let the VPC endpoint add this context to the request.&lt;/p&gt;

&lt;p&gt;And according to the chalk talk session, the &lt;code&gt;aws:SourceVpc&lt;/code&gt; context is added when the API call goes through the VPC endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F85d12612-0bb7-45c9-9bab-3d03d445dd1e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F85d12612-0bb7-45c9-9bab-3d03d445dd1e.jpg" alt="Request contexts are added at different stages of the traffic path"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Request contexts are added at different stages of the traffic path&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How AWS documentation fails to make its users understand
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Does it really mean the source VPC?
&lt;/h3&gt;

&lt;p&gt;Now we know the &lt;code&gt;aws:SourceVpc&lt;/code&gt; context is added by the VPC endpoint. So does it really mean "Source VPC"?&lt;/p&gt;

&lt;p&gt;Consider the following scenario:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Fdbde9353-9842-4f1c-ac81-0620eae7bc5e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Fdbde9353-9842-4f1c-ac81-0620eae7bc5e.jpg" alt="VPC endpoint sharing"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;VPC endpoint sharing&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I have 2 VPCs (&lt;code&gt;vpc-aaaaaaa&lt;/code&gt; and &lt;code&gt;vpc-bbbbbbb&lt;/code&gt;) with VPC peering. An STS VPC endpoint in &lt;code&gt;vpc-aaaaaaa&lt;/code&gt;, and an EC2 instance in &lt;code&gt;vpc-bbbbbbb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, I want to restrict an IAM role only to be assumed through the blue route; what should I specify in the IAM policy?&lt;/p&gt;

&lt;p&gt;Imagine if I didn't attend the chalk talk session and just read the AWS documentation, which states &lt;em&gt;Use this key to check whether the request comes from the VPC that you specify in the policy.&lt;/em&gt;. I would definitely write my policy as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"Condition"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"StringEquals"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"aws:SourceVpc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vpc-bbbbbbb"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But does it work? I did an experiment:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I created an EC2 instance in &lt;code&gt;vpc-05c07e7f&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F84a706bf-459e-4be8-83ae-7fb64c05d21d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F84a706bf-459e-4be8-83ae-7fb64c05d21d.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I created an STS VPC endpoint in another VPC, &lt;code&gt;vpc-0c3610a65f744e73f&lt;/code&gt;, which is peered with the first VPC.&lt;br&gt;
Its private IP address is &lt;code&gt;10.0.0.186&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Faadd01b8-d839-491e-b112-ecfbb7196528.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Faadd01b8-d839-491e-b112-ecfbb7196528.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F18e21b8d-63e6-49cd-bd44-d9f6755bd57b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F18e21b8d-63e6-49cd-bd44-d9f6755bd57b.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then I attached an IAM policy into the EC2 IAM role, using &lt;code&gt;vpc-05c07e7f&lt;/code&gt;, which is the VPC containing the EC2 instance&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F0b9b4e21-c66d-4261-8ccb-ff5f95d8b0e8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F0b9b4e21-c66d-4261-8ccb-ff5f95d8b0e8.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I logged into the EC2 instance and verified the STS request will go to the VPC endpoint IP address.&lt;br&gt;
Then my &lt;code&gt;sts:assumeRole&lt;/code&gt; CLI command was denied&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Ff6f206b4-3b55-4f21-b039-2d29108aa814.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Ff6f206b4-3b55-4f21-b039-2d29108aa814.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then I changed the IAM policy to use &lt;code&gt;vpc-0c3610a65f744e73f&lt;/code&gt;, which contains the VPC endpoint&lt;br&gt;
The CLI command was successful this time.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F00fe33ce-c499-47ef-b76e-4851d8ac3f73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2F00fe33ce-c499-47ef-b76e-4851d8ac3f73.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Fe1a980e4-e34b-48b2-bc18-84b60c59872e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.richardfan.xyz%2Fassets%2Fimages%2Fe1a980e4-e34b-48b2-bc18-84b60c59872e.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Of course, after learning how request contexts are added, I know why &lt;code&gt;aws:SourceVpc&lt;/code&gt; is not where the request is really coming from.&lt;/p&gt;

&lt;p&gt;The context is added by the VPC endpoint, it doesn't care where the request comes from. As long as the request is going through the VPC endpoint, it will add the VPC ID of itself.&lt;/p&gt;

&lt;p&gt;But it clearly doesn't match the documentation description.&lt;/p&gt;

&lt;h2&gt;
  
  
  Call for action to AWS
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Make the documentation more accurate&lt;/strong&gt;&lt;br&gt;
Clearly, the &lt;code&gt;aws:SourceVpc&lt;/code&gt; doesn't actually represent &lt;em&gt;whether the request comes from the VPC....&lt;/em&gt;. So, the IAM team must change the wording.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Publish the process under the hood&lt;/strong&gt;&lt;br&gt;
AWS environment is complex, and it's difficult to explain something within a few lines.&lt;br&gt;
If someone really wants to customize the AWS environment, the best way to let them understand is to publish the system details.&lt;br&gt;
I believe if I can learn the request context and IAM condition matching process from a chalk talk session, it's not a secret. So why doesn't AWS publish the whole process in their documentation and let the architect read and decide what their IAM policy and VPC configuration should look like?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Let the appropriate team write the documentation&lt;/strong&gt;&lt;br&gt;
One of the arguing points I had in the discussion is: "Does this &lt;code&gt;aws:SourceVpc&lt;/code&gt; condition only works on S3?"&lt;br&gt;
The reason for this argument is that when we read the documentation and want to see more details, it directs us to the S3 documentation: &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies-vpc-endpoint.html#example-bucket-policies-restrict-access-vpc" rel="noopener noreferrer"&gt;Restricting Access to a Specific VPC&lt;/a&gt;&lt;br&gt;
Then I asked myself, VPC endpoint is the VPC team's product, and IAM policy is managed by the IAM team, especially when this is a global condition key. So why would the responsibility of explaining it go to the S3 team?&lt;br&gt;
I understand that maybe the S3 team has written an excellent documentation and the IAM team wants to borrow it.&lt;br&gt;
But can the IAM team at least give it a stamp and move it into the IAM documentation? So we, as AWS users, can be less confused about whether some features are specific to one service? Or is it common to all services?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>aws</category>
      <category>iam</category>
      <category>vpc</category>
      <category>cloudsecurity</category>
    </item>
    <item>
      <title>Start building my AWS Clean Rooms lab</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Tue, 02 Jan 2024 02:10:48 +0000</pubDate>
      <link>https://forem.com/aws-builders/start-building-my-aws-clean-rooms-lab-1dii</link>
      <guid>https://forem.com/aws-builders/start-building-my-aws-clean-rooms-lab-1dii</guid>
      <description>&lt;p&gt;Last month, I had a &lt;a href="https://www.linkedin.com/posts/richardfan1126_from-privacy-to-partnership-the-royal-society-activity-7142354202655084544-ikbi"&gt;post on Linkedin&lt;/a&gt; about AWS Clean Rooms Differential Privacy. But I was not comfortable sharing something that I've never used. So I spent some time to try it, but then hit the wall so hard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is it so challenging to try a clean room service?
&lt;/h2&gt;

&lt;p&gt;First of all, the name &lt;strong&gt;Clean Room&lt;/strong&gt; is not coined by AWS. &lt;strong&gt;Data clean room&lt;/strong&gt; is a concept of analyzing data in an isolated environment so multiple parties can bring their data together to produce insight without compromising data privacy.&lt;/p&gt;

&lt;p&gt;The difficulties of getting started are not specific to AWS Clean Rooms. It's more about the nature of a data clean room:&lt;/p&gt;

&lt;h3&gt;
  
  
  Multi-party collaboration
&lt;/h3&gt;

&lt;p&gt;Data clean room is about collaboration between different parties. To simulate this environment, we must utilize multiple AWS accounts to get a sense of the service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reliance on good data
&lt;/h3&gt;

&lt;p&gt;We can't feed random data into a data clean room to get some meaningful output. First, we must have 2 different datasets because we are simulating a multi-party collaboration. Second, these 2 data must have some relationship.&lt;/p&gt;

&lt;p&gt;Apparently, we can't bring a list of Netflix movies and a bus route table together and hope to get some meaningful insight from them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lack of online resources
&lt;/h3&gt;

&lt;p&gt;This is probably the major reason.&lt;/p&gt;

&lt;p&gt;I tried to search on &lt;a href="https://aws.amazon.com/clean-rooms/"&gt;AWS official website&lt;/a&gt; to find resources. What I got is a lovely architecture diagram and a &lt;a href="https://aws.amazon.com/clean-rooms/resources/#Demo"&gt;pre-recorded demo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I tried to search on &lt;a href="https://workshops.aws/"&gt;AWS workshop website&lt;/a&gt; using the keyword &lt;strong&gt;Clean&lt;/strong&gt;. The only thing that popped up is &lt;strong&gt;Service Cloud Voice Series: Cleaning up your environment&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I can try &lt;em&gt;ClickOps&lt;/em&gt; on the console without a tutorial and figure it out myself. But I still need some good data to play with.&lt;/p&gt;

&lt;p&gt;I tried searching on &lt;a href="https://www.kaggle.com/"&gt;Kaggle&lt;/a&gt;, and also on Google using keywords like &lt;em&gt;"data clean room lab csv"&lt;/em&gt;, &lt;em&gt;"data clean room sample data"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;But the data I got are either not clean enough or have only 1 table, which I can't simulate a data collaboration.&lt;/p&gt;

&lt;h2&gt;
  
  
  That's why I'm creating my own lab
&lt;/h2&gt;

&lt;p&gt;I was frustrated, but I don't want other people like me to be frustrated too. So, I decided to build an easy-to-follow lab on AWS Clean Rooms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding a suitable dataset
&lt;/h3&gt;

&lt;p&gt;After trying harder and harder &lt;em&gt;(I learned this during my OSCP course)&lt;/em&gt;, I finally found some useful sample data from &lt;a href="https://mavenanalytics.io/data-playground"&gt;Maven Analytics&lt;/a&gt;. And more importantly, their data is in the public domain, meaning I can freely use it in my lab. I picked the &lt;strong&gt;Airline Loyalty Program&lt;/strong&gt; data in my lab.&lt;/p&gt;

&lt;h3&gt;
  
  
  IaC everything
&lt;/h3&gt;

&lt;p&gt;Another intimidating thing about AWS Clean Rooms is that we must jump between AWS accounts to finish the setup. It doesn't just make &lt;em&gt;ClickOps&lt;/em&gt; complicated, but also IaC.&lt;/p&gt;

&lt;p&gt;I usually use CloudFormation when working on public AWS projects because it's native to AWS. But this time, I'm mixing CloudFormation with Terraform because of its easy-to-setup multi-account deployment. I hope AWS can learn from Hashicorp in this aspect and make it easier to deploy stuff remotely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's the link
&lt;/h2&gt;

&lt;p&gt;After talking so much, here's the link to my still-in-progress AWS Clean Rooms Lab: &lt;a href="https://github.com/richardfan1126/aws-clean-rooms-lab"&gt;https://github.com/richardfan1126/aws-clean-rooms-lab&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This lab is not completed yet. But it has 2 sessions already, which you can go through, start playing, and get meaningful results.&lt;/p&gt;

&lt;p&gt;What's more exciting is that if you just want to play with the analysis rules and queries and don't want to deal with all the infrastructure hustle, you can simply run a few commands, and everything will be set for you.&lt;/p&gt;

&lt;p&gt;I will continue creating more sessions on more complex analysis rules. And more interestingly, the differential privacy part.&lt;/p&gt;

</description>
      <category>cloudsecurity</category>
      <category>dataprivacy</category>
      <category>privacyenhancingtechnologies</category>
      <category>aws</category>
    </item>
    <item>
      <title>A playground to practice differential privacy - Antigranular</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Tue, 26 Dec 2023 14:47:09 +0000</pubDate>
      <link>https://forem.com/richardfan1126/a-playground-to-practice-differential-privacy-antigranular-32aj</link>
      <guid>https://forem.com/richardfan1126/a-playground-to-practice-differential-privacy-antigranular-32aj</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Background&lt;br&gt;
 2. What is Antigranular&lt;br&gt;
 3. My quick walkthrough - as a non-data engineer&lt;br&gt;
       3.1. Create a Jupyter Notebook&lt;br&gt;
       3.2. Running some basic data engineering tasks&lt;br&gt;
       3.3. Do some machine learning tasks&lt;br&gt;
 4. Why I think it is useful&lt;br&gt;
 5. How I think as a security engineer&lt;br&gt;
       5.1. Verifiable TEE&lt;br&gt;
       5.2. Threat modelling&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;I knew Jack from &lt;a href="https://www.oblivious.com/"&gt;Oblivious&lt;/a&gt; (His company was called Oblivious AI then) early this year when I was researching companies that use &lt;a href="https://aws.amazon.com/ec2/nitro/nitro-enclaves/"&gt;AWS Nitro Enclaves&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At that time, their tool was just helping users deploy simple applications in the enclaves, and I didn't understand how it was related to data science or even AI.&lt;/p&gt;

&lt;p&gt;Last month in AWS re:Invent, I met Jack in person for the first time. After a great chat with him, I finally understood what his company was trying to achieve.&lt;/p&gt;

&lt;p&gt;And today's post is to share my first-glance view on the Oblivious platform - &lt;a href="https://www.antigranular.com/"&gt;Antigranular&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Antigranular
&lt;/h2&gt;

&lt;p&gt;Antigranular is a Kaggle-like platform where we can play with various datasets, joining competitions on machine learning and data science using those datasets.&lt;/p&gt;

&lt;p&gt;The difference from Kaggle is that Antigranular's dataset is not freely available. Instead, there are restrictions on how users can access their data in order to guarantee data privacy.&lt;/p&gt;

&lt;p&gt;There is another &lt;a href="https://pub.towardsai.net/antigranular-how-to-access-sensitive-datasets-without-looking-at-them-44090cb22d8a"&gt;blog post&lt;/a&gt; by Bex T. talking about what is Antigranular, what technique it is applying, and how to get started. You can read it if you are interested in the details.&lt;/p&gt;

&lt;h2&gt;
  
  
  My quick walkthrough - as a non-data engineer
&lt;/h2&gt;

&lt;p&gt;I'm not a data engineer, and I don't even know the difference between &lt;code&gt;pandas&lt;/code&gt; and &lt;code&gt;numpy&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But I still tried to create my Jupyter notebook to play with one sandbox competition on Antigranular.&lt;/p&gt;

&lt;p&gt;If you are also not a data engineer and have no idea how DataFrame works, my walkthrough may help you understand Antigranular and differential privacy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a Jupyter Notebook
&lt;/h3&gt;

&lt;p&gt;To play with the dataset, we first must create a Jupyter notebook, a powerful and popular tool among data engineers. I created mine on &lt;a href="https://colab.research.google.com/"&gt;Google Colab&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VKlufFQM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/c45ce549-fdff-4adc-a770-72573805d5cf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VKlufFQM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/c45ce549-fdff-4adc-a770-72573805d5cf.png" alt="Using Google Colab to create a Jupyter notebook" width="800" height="867"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Jupyter notebook can run different programming languages. Since Antigranular provides a Python library, I will be using Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running some basic data engineering tasks
&lt;/h3&gt;

&lt;p&gt;Before playing with the dataset, I need to mention a major difference between Antigranular and other data platforms - The data is not loaded into our Jupyter notebook.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UhYXS9EO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/4e0c878c-e9da-42e1-b031-9cf45cfacb9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UhYXS9EO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/4e0c878c-e9da-42e1-b031-9cf45cfacb9a.png" alt="Data cannot be accessed on local notebook" width="653" height="659"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see from the screenshot that if I access the data and try to get its metadata, it will raise an error.&lt;/p&gt;

&lt;p&gt;Instead, the data is being loaded in a trusted execution environment (TEE) hosted by Antigranular.&lt;/p&gt;

&lt;p&gt;To access the TEE, we must add a magic function &lt;code&gt;%%ag&lt;/code&gt; into the code block. The magic is that we can only use limited libraries and functions in those code blocks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4LOZEnas--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2fe7b0c5-15d6-41ba-b145-de0405231427.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4LOZEnas--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2fe7b0c5-15d6-41ba-b145-de0405231427.png" alt="The operation in the TEE is limited" width="612" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Data engineers usually use the &lt;code&gt;head()&lt;/code&gt; function to preview the data. But with &lt;code&gt;op_pandas&lt;/code&gt;, this action is blocked.&lt;/p&gt;

&lt;p&gt;With these restrictions, the Antigranular platform can assure data providers that the individual privacy inside the dataset is protected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do some machine learning tasks
&lt;/h3&gt;

&lt;p&gt;Now, we know that Antigranular runtime is an environment with limited visibility to the dataset. But what is our goal?&lt;/p&gt;

&lt;p&gt;Inside the dataset, there are training data and testing data. We need to use our limited access to the training data to train an ML model. Then, it is used to predict the outcome from the testing data.&lt;/p&gt;

&lt;p&gt;The catch is that our privacy budget will be used whenever we access the training data.&lt;/p&gt;

&lt;p&gt;I'm not a data scientist, so I won’t explain privacy budget and differential privacy in detail.&lt;/p&gt;

&lt;p&gt;But the idea is that:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If we run enough amount of targeted queries on a dataset, we can interpolate some detail from an individual record.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And differential privacy is all about limiting such a scenario. The less privacy budget we use, the less likely we can interpolate individual records.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Of course, if we want to train a good ML model, we should train it with accurate data. But the catch here is that we also want to protect individual privacy.&lt;/p&gt;

&lt;p&gt;So, the competition on Antigranular is to train an ML model using as little of a privacy budget as possible. And use it to predict the test data as accurately as possible and submit that prediction result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SXsSnT_p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2c1fef93-b645-4e9f-84e6-420b26073f2c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SXsSnT_p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2c1fef93-b645-4e9f-84e6-420b26073f2c.png" alt="Using Gaussian Naive Bayes" width="588" height="181"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I know little about supervised ML, so I used a simple Gaussian Naive Bayes model trained by the training data with 0.1 privacy budget (or &lt;strong&gt;epsilon&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vXKcutXm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/af095714-5b0d-4430-9ebf-ab24a99307e0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vXKcutXm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/af095714-5b0d-4430-9ebf-ab24a99307e0.png" alt="Submit the prediction and get the score" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, I used the model to predict the outcome from the test data and submitted it.&lt;/p&gt;

&lt;p&gt;As expected, I got around &lt;strong&gt;0.27&lt;/strong&gt; points, far lower than other submissions, at around 0.7.&lt;/p&gt;

&lt;p&gt;Another thing we can see here is the privacy budget I've used so far (i.e. &lt;code&gt;total_epsilon_used&lt;/code&gt;) on the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I think it is useful
&lt;/h2&gt;

&lt;p&gt;Many Privacy Enhancing Technologies (PET) are emerging, like Trusted Execution Environment, Homomorphic Encryption, Synthetic data, etc. Most of them only require the skills and knowledge of the developers.&lt;/p&gt;

&lt;p&gt;However, for differential privacy, the users must also have the skills. We can see from the walkthrough that even how we query the data or how many queries we run will affect the privacy budget we will be using.&lt;/p&gt;

&lt;p&gt;Not just for engineers, data analysts also need to learn how to interact with Differentially Private datasets. And I think Antigranular is a great place to play and learn.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I think as a security engineer
&lt;/h2&gt;

&lt;p&gt;After talking about data engineering, let me come back to my security engineer role. How do I think about it?&lt;/p&gt;

&lt;h3&gt;
  
  
  Verifiable TEE
&lt;/h3&gt;

&lt;p&gt;The core of Trusted Execution Environment (TEE) is to ensure data is being processed in a &lt;strong&gt;trusted hardware&lt;/strong&gt; that is running a &lt;strong&gt;trusted software&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The core part of &lt;code&gt;oblv_client&lt;/code&gt; library, which is used by &lt;code&gt;antigranular&lt;/code&gt; library to connect with the TEE runtime on Antigranular, is compiled so I can't see if they are using the &lt;a href="https://docs.aws.amazon.com/enclaves/latest/user/verify-root.html"&gt;process&lt;/a&gt; to verify if the code is running on a genuine AWS Nitro Enclaves. But I tend to believe it is.&lt;/p&gt;

&lt;p&gt;The other question is the &lt;strong&gt;trusted software&lt;/strong&gt;. From the &lt;a href="https://docs.antigranular.com/"&gt;documentation&lt;/a&gt; and the &lt;a href="https://github.com/orgs/ObliviousAI/repositories"&gt;GitHub page&lt;/a&gt; of Antigranular, I cannot find any code of their TEE. The fingerprint of the TEE, which the client will verify against during the Jupyter notebook initialization, is from an Antigranular API. So, we can only trust that the software inside the TEE is safe and honest.&lt;/p&gt;

&lt;p&gt;Even though we trust Antigranular or maybe some parties can access the source code of the TEE, there is still another problem: &lt;strong&gt;Reproducible build&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To verify whether a TEE is running the exact same software, we must ensure the fingerprint is always the same.&lt;/p&gt;

&lt;p&gt;But many factors can make the compiled software different, e.g. time of build, software dependencies, etc., especially when the Antigranular runtime relies on many libraries written in Python, which is always inconsistent during build time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Threat modelling
&lt;/h3&gt;

&lt;p&gt;A common way to do threat modelling in cybersecurity is to ask: Is it a risk? How critical is it? How to mitigate it? How do we detect it?&lt;/p&gt;

&lt;p&gt;But for differential privacy, it's a little bit tricky.&lt;/p&gt;

&lt;p&gt;Is the data critical? &lt;em&gt;Yes, of course! There are many PII&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, there is a risk of data breach. Let's lock it up. &lt;em&gt;No, we need to share with other party to do research&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;OK, but how do you mitigate the risk of data breach? &lt;em&gt;We can set the differential privacy policy, but you need to figure out the parameters&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Can we set an alarm when someone accesses the sensitive data? &lt;em&gt;Our counterpart is supposed to have some access to the data. How can we define what is sensitive?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I can't imagine how I would react if the data team asked me to do threat modelling for their data clean room with differential privacy today.&lt;/p&gt;

&lt;p&gt;However, I think differential privacy will definitely change how we protect data in the future, and we must learn its capability and limitations.&lt;/p&gt;

</description>
      <category>cloudsecurity</category>
      <category>dataprivacy</category>
      <category>dataprotection</category>
    </item>
    <item>
      <title>First Try on AWS Security Hub Central Configuration</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Tue, 26 Dec 2023 14:36:14 +0000</pubDate>
      <link>https://forem.com/aws-builders/first-try-on-aws-security-hub-central-configuration-4kni</link>
      <guid>https://forem.com/aws-builders/first-try-on-aws-security-hub-central-configuration-4kni</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Help us manage security controls in one place&lt;br&gt;
 2. The caveats&lt;br&gt;
       2.1. Don't forget to enable AWS Config if you want to get findings&lt;br&gt;
       2.2. Use the right template&lt;br&gt;
 3. Painful experiment&lt;/p&gt;

&lt;p&gt;In my previous &lt;a href="https://dev.to/aws-builders/my-thoughts-on-aws-reinvent-2023-announcements-1m3b#aws-security-hub-central-configuration"&gt;post&lt;/a&gt;, I've mentioned the new AWS Security Hub Central Configuration feature. I thought AWS finally solved the headache we face when managing Security Hub in cross-account, cross-region environments. It's kind of true, but not a lot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Help us manage security controls in one place
&lt;/h2&gt;

&lt;p&gt;Let's talk about the good first. Security Hub central configuration helps us manage the security controls on different accounts, different regions.&lt;/p&gt;

&lt;p&gt;When we enable central configuration, we can pick the regions, and the policy we create later will be deployed to the selected regions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TZZKN2H3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b1693d52-aba7-47d0-903b-6b70c267d01e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TZZKN2H3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b1693d52-aba7-47d0-903b-6b70c267d01e.png" alt="Select regions to deploy configuration" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can then create different policies on the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What security standards to deploy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What controls to enable/disable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customize control parameters&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MRtq7ahn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f4bd32ea-5255-412a-8f94-a19b695b9f73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MRtq7ahn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f4bd32ea-5255-412a-8f94-a19b695b9f73.png" alt="Setting configuration policy" width="784" height="807"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These policies can be deployed to all accounts or the accounts we specify so that we can configure different accounts differently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x4exnuJj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8a7d7a12-5151-40e8-a59d-79142fc1dd44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x4exnuJj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8a7d7a12-5151-40e8-a59d-79142fc1dd44.png" alt="Deploy policy to specified accounts" width="791" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The caveats
&lt;/h2&gt;

&lt;p&gt;OK, we've finished talking about the good part. Let's talk about the dark side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Don't forget to enable AWS Config if you want to get findings
&lt;/h3&gt;

&lt;p&gt;So the AWS &lt;a href="https://aws.amazon.com/blogs/security/introducing-new-central-configuration-capabilities-in-aws-security-hub/"&gt;blog post&lt;/a&gt; claimed we can &lt;em&gt;"using a single action to enable Security Hub across your organization"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f8-kYUKQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8827cf83-ce12-4996-b611-f488cd699889.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f8-kYUKQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8827cf83-ce12-4996-b611-f488cd699889.png" alt="AWS blog claimed we can enable Security Hub across organization using a single action" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right, but it only turns on Security Hub. If we want to get findings, we still need to enable AWS Config on all the accounts, ... manually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SxaB34_3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2f5d6826-345d-4ef9-9ef1-c4c32d7fc1fc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SxaB34_3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2f5d6826-345d-4ef9-9ef1-c4c32d7fc1fc.png" alt="Enabling AWS Config is still manually" width="787" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OK, fine!! So I scrolled down a little bit and found this.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"if AWS Config is not yet enabled in an account, the policy will have a failed status."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--shzeXxiu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f2fbee64-e81f-486f-813b-9cded119c0da.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--shzeXxiu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f2fbee64-e81f-486f-813b-9cded119c0da.png" alt="Failure when AWS Config is not enabled" width="792" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I then tried to deploy Security Hub on my AWS Organization, which I only turned on Config on 1 account.&lt;/p&gt;

&lt;p&gt;Guess what? I got the green lights for all 3 accounts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BcBaohy2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b2da5bbb-631e-4aa1-8ecd-b4dd2a858abc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BcBaohy2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b2da5bbb-631e-4aa1-8ecd-b4dd2a858abc.png" alt="Deployment success even some accounts don't have Config enabled" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maybe I forgot that I had enabled Config on these accounts, or maybe Security Hub helped me turn them on?&lt;/p&gt;

&lt;p&gt;So, I waited 2 days for the findings to come. But then, the account that had Config enabled already had many findings, but the 2 without Config only got 17 findings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g0aBaPp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/3e828951-ecc2-49d9-b360-a690d3d86af4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g0aBaPp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/3e828951-ecc2-49d9-b360-a690d3d86af4.png" alt="Accounts without Config only got 17 findings" width="771" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I went on and used CloudFormation StackSet to enable AWS Config for these 2 accounts.&lt;/p&gt;

&lt;p&gt;At that point, I was pretty sure AWS Config was not enabled because the StackSet wouldn't succeed if so.&lt;/p&gt;

&lt;p&gt;I don't know what's going wrong, but after enabling AWS Config, the findings finally came.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eDHddolk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/abaeb29b-0991-4dda-a43b-e59de511afe3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eDHddolk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/abaeb29b-0991-4dda-a43b-e59de511afe3.png" alt="Findings started coming after enabling AWS Config" width="776" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I still don't understand why the error message didn't come.&lt;/p&gt;

&lt;p&gt;But the main takeaway is: &lt;strong&gt;Make sure you have AWS Config enabled on all relevant accounts if you want to get findings from AWS Security Hub&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use the right template
&lt;/h3&gt;

&lt;p&gt;Another interesting point (but not related to this new feature) is the template we use to enable AWS Config.&lt;/p&gt;

&lt;p&gt;The CloudFormation StackSet console has a sample template called "Enable AWS Config".&lt;/p&gt;

&lt;p&gt;But if you only want to get AWS Security Hub findings, &lt;strong&gt;DON'T&lt;/strong&gt; use it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VVfTT_2e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/4278c5ad-012d-48c1-a1fc-5152ac73b7e5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VVfTT_2e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/4278c5ad-012d-48c1-a1fc-5152ac73b7e5.png" alt="Don't use the default StackSet template to enable AWS Config" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is another StackSet template &lt;a href="https://github.com/aws-samples/aws-cfn-for-optimizing-aws-config-for-aws-security-hub/blob/main/AWS-Config-optimized-for-AWS-Security-Hub.yaml"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This template only enables configuration recording on resource types that Security Hub cares about.&lt;/p&gt;

&lt;p&gt;Using this one could help you save money by not recording resources that Security Hub doesn't look at.&lt;/p&gt;

&lt;h2&gt;
  
  
  Painful experiment
&lt;/h2&gt;

&lt;p&gt;So, now I still can't figure out why my child accounts could pass the checking even though AWS Config was not enabled.&lt;/p&gt;

&lt;p&gt;I'll need to create another clean AWS Organization to test out.&lt;/p&gt;

&lt;p&gt;Experimenting with things on Cloud Governance is really a painful task.&lt;/p&gt;

&lt;p&gt;I can't simply nuke the resources to restart because what I'm testing is the Organizations; the accounts.&lt;/p&gt;

&lt;p&gt;And now, I need to restart everything again.&lt;/p&gt;

&lt;p&gt;In my previous &lt;a href="https://dev.to/aws-builders/my-thoughts-on-aws-reinvent-2023-announcements-1m3b#aws-security-hub-central-configuration"&gt;post&lt;/a&gt;, I've mentioned the new AWS Security Hub Central Configuration feature. I thought AWS finally solved the headache we face when managing Security Hub in cross-account, cross-region environments. It's kind of true, but not a lot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Help us manage security controls in one place
&lt;/h2&gt;

&lt;p&gt;Let's talk about the good first. Security Hub central configuration helps us manage the security controls on different accounts, different regions.&lt;/p&gt;

&lt;p&gt;When we enable central configuration, we can pick the regions, and the policy we create later will be deployed to the selected regions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TZZKN2H3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b1693d52-aba7-47d0-903b-6b70c267d01e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TZZKN2H3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b1693d52-aba7-47d0-903b-6b70c267d01e.png" alt="Select regions to deploy configuration" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can then create different policies on the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;What security standards to deploy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What controls to enable/disable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customize control parameters&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MRtq7ahn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f4bd32ea-5255-412a-8f94-a19b695b9f73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MRtq7ahn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f4bd32ea-5255-412a-8f94-a19b695b9f73.png" alt="Setting configuration policy" width="784" height="807"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These policies can be deployed to all accounts or the accounts we specify so that we can configure different accounts differently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x4exnuJj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8a7d7a12-5151-40e8-a59d-79142fc1dd44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x4exnuJj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8a7d7a12-5151-40e8-a59d-79142fc1dd44.png" alt="Deploy policy to specified accounts" width="791" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The caveats
&lt;/h2&gt;

&lt;p&gt;OK, we've finished talking about the good part. Let's talk about the dark side.&lt;/p&gt;

&lt;h3&gt;
  
  
  Don't forget to enable AWS Config if you want to get findings
&lt;/h3&gt;

&lt;p&gt;So the AWS &lt;a href="https://aws.amazon.com/blogs/security/introducing-new-central-configuration-capabilities-in-aws-security-hub/"&gt;blog post&lt;/a&gt; claimed we can &lt;em&gt;"using a single action to enable Security Hub across your organization"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f8-kYUKQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8827cf83-ce12-4996-b611-f488cd699889.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f8-kYUKQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/8827cf83-ce12-4996-b611-f488cd699889.png" alt="AWS blog claimed we can enable Security Hub across organization using a single action" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right, but it only turns on Security Hub. If we want to get findings, we still need to enable AWS Config on all the accounts, ... manually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SxaB34_3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2f5d6826-345d-4ef9-9ef1-c4c32d7fc1fc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SxaB34_3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/2f5d6826-345d-4ef9-9ef1-c4c32d7fc1fc.png" alt="Enabling AWS Config is still manually" width="787" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OK, fine!! So I scrolled down a little bit and found this.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"if AWS Config is not yet enabled in an account, the policy will have a failed status."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--shzeXxiu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f2fbee64-e81f-486f-813b-9cded119c0da.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--shzeXxiu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/f2fbee64-e81f-486f-813b-9cded119c0da.png" alt="Failure when AWS Config is not enabled" width="792" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I then tried to deploy Security Hub on my AWS Organization, which I only turned on Config on 1 account.&lt;/p&gt;

&lt;p&gt;Guess what? I got the green lights for all 3 accounts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BcBaohy2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b2da5bbb-631e-4aa1-8ecd-b4dd2a858abc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BcBaohy2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/b2da5bbb-631e-4aa1-8ecd-b4dd2a858abc.png" alt="Deployment success even some accounts don't have Config enabled" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maybe I forgot that I had enabled Config on these accounts, or maybe Security Hub helped me turn them on?&lt;/p&gt;

&lt;p&gt;So, I waited 2 days for the findings to come. But then, the account that had Config enabled already had many findings, but the 2 without Config only got 17 findings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g0aBaPp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/3e828951-ecc2-49d9-b360-a690d3d86af4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g0aBaPp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/3e828951-ecc2-49d9-b360-a690d3d86af4.png" alt="Accounts without Config only got 17 findings" width="771" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I went on and used CloudFormation StackSet to enable AWS Config for these 2 accounts.&lt;/p&gt;

&lt;p&gt;At that point, I was pretty sure AWS Config was not enabled because the StackSet wouldn't succeed if so.&lt;/p&gt;

&lt;p&gt;I don't know what's going wrong, but after enabling AWS Config, the findings finally came.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eDHddolk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/abaeb29b-0991-4dda-a43b-e59de511afe3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eDHddolk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/abaeb29b-0991-4dda-a43b-e59de511afe3.png" alt="Findings started coming after enabling AWS Config" width="776" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I still don't understand why the error message didn't come.&lt;/p&gt;

&lt;p&gt;But the main takeaway is: &lt;strong&gt;Make sure you have AWS Config enabled on all relevant accounts if you want to get findings from AWS Security Hub&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use the right template
&lt;/h3&gt;

&lt;p&gt;Another interesting point (but not related to this new feature) is the template we use to enable AWS Config.&lt;/p&gt;

&lt;p&gt;The CloudFormation StackSet console has a sample template called "Enable AWS Config".&lt;/p&gt;

&lt;p&gt;But if you only want to get AWS Security Hub findings, &lt;strong&gt;DON'T&lt;/strong&gt; use it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VVfTT_2e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/4278c5ad-012d-48c1-a1fc-5152ac73b7e5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VVfTT_2e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://blog.richardfan.xyz/assets/images/4278c5ad-012d-48c1-a1fc-5152ac73b7e5.png" alt="Don't use the default StackSet template to enable AWS Config" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is another StackSet template &lt;a href="https://github.com/aws-samples/aws-cfn-for-optimizing-aws-config-for-aws-security-hub/blob/main/AWS-Config-optimized-for-AWS-Security-Hub.yaml"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This template only enables configuration recording on resource types that Security Hub cares about.&lt;/p&gt;

&lt;p&gt;Using this one could help you save money by not recording resources that Security Hub doesn't look at.&lt;/p&gt;

&lt;h2&gt;
  
  
  Painful experiment
&lt;/h2&gt;

&lt;p&gt;So, now I still can't figure out why my child accounts could pass the checking even though AWS Config was not enabled.&lt;/p&gt;

&lt;p&gt;I'll need to create another clean AWS Organization to test out.&lt;/p&gt;

&lt;p&gt;Experimenting with things on Cloud Governance is really a painful task.&lt;/p&gt;

&lt;p&gt;I can't simply nuke the resources to restart because what I'm testing is the Organizations; the accounts.&lt;/p&gt;

&lt;p&gt;And now, I need to restart everything again.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudsecurity</category>
      <category>securityhub</category>
    </item>
    <item>
      <title>Operation Fire Valley Rocks</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Sat, 16 Dec 2023 03:20:00 +0000</pubDate>
      <link>https://forem.com/aws-builders/operation-fire-valley-rocks-4mi6</link>
      <guid>https://forem.com/aws-builders/operation-fire-valley-rocks-4mi6</guid>
      <description>&lt;p&gt;I'm not a poet, and it's difficult for me to write a 10-verse poem.&lt;/p&gt;

&lt;p&gt;But luckily, this year is all about GenAI. I used GenAI to help me rewrite the poem &lt;a href="https://dev.to/jennworks40"&gt;Jenn Bergstrom&lt;/a&gt; has written.&lt;/p&gt;

&lt;p&gt;Using Step Functions to make a Christmas Tree reminds me of the grand old days of ASCII art. And here is the Step Functions Christmas Tree I've created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iO6wjbOu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qdklnw2r51atkk740cug.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iO6wjbOu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qdklnw2r51atkk740cug.jpg" alt="My Step Functions Christmas Tree" width="800" height="656"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2023 has been an adventurous year for me. I'm so thankful to the AWS Community Builders and those who make this program great.&lt;/p&gt;

&lt;p&gt;This year, I've met many CBs on different occasions. The CB program makes me feel like I am part of the community; I know where I can find people to talk to and where I can participate.&lt;/p&gt;

&lt;p&gt;Of course, being recognized as an AWS Security Hero is the biggest thing to me this year. Although it's just a month ago, it feels like time has passed a long way already.&lt;/p&gt;

&lt;p&gt;Again, I'm so thankful to the people who have helped me, and pushed me along the way, Jason Dunn, Lily Kerns, Taylor Jacobsen, Johannes Koch, Chris Williams, ... &lt;em&gt;(No specific order)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And, of course, thanks to the AWS community in Hong Kong, Amy Wong, Gabriel Koo, Anthony Lai. My fellow AWS Heroes from HK, Cyrus Wong, and Alex Lau. &lt;em&gt;(No specific order)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>communitybuilders</category>
      <category>thankfulforest2024</category>
      <category>firevalleyrocks</category>
    </item>
    <item>
      <title>My thoughts on AWS re:Invent 2023 announcements</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Thu, 07 Dec 2023 15:37:47 +0000</pubDate>
      <link>https://forem.com/aws-builders/my-thoughts-on-aws-reinvent-2023-announcements-1m3b</link>
      <guid>https://forem.com/aws-builders/my-thoughts-on-aws-reinvent-2023-announcements-1m3b</guid>
      <description>&lt;p&gt; 1. Preface&lt;br&gt;
 2. Good ones&lt;br&gt;
       2.1. AWS Security Hub central configuration&lt;br&gt;
       2.2. AWS Security Hub custom control parameters&lt;br&gt;
       2.3. Amazon GuardDuty ECS Runtime Monitoring&lt;br&gt;
       2.4. Amazon Inspector agentless vulnerability assessments&lt;br&gt;
 3. Still good ones, but just ... disappointed&lt;br&gt;
       3.5. AWS Config periodic recording&lt;br&gt;
       3.6. Amazon S3 Access Grants&lt;br&gt;
 4. GenAI&lt;br&gt;
       4.7. Guardrails for Amazon Bedrock&lt;br&gt;
       4.8. Responsible AI - Amazon Titan image watermark&lt;br&gt;
       4.9. GenAI help cybersecurity&lt;/p&gt;

&lt;h2&gt;
  
  
  Preface
&lt;/h2&gt;

&lt;p&gt;This year is all about GenAI, and AWS re:Invent is no exception, almost half of the announcements are about GenAI, especially &lt;a href="https://aws.amazon.com/blogs/aws/introducing-amazon-q-a-new-generative-ai-powered-assistant-preview/" rel="noopener noreferrer"&gt;Amazon Q&lt;/a&gt; &lt;em&gt;(I still don't like this name)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;However, as a cloud security guy, some other announcements also interest me, and here are my thoughts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Good ones
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AWS Security Hub central configuration
&lt;/h3&gt;

&lt;p&gt;Yes! This one! It's not a fancy one, you probably didn't notice it, but this one tops my list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fyh4xowuerybgvcrvxm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fyh4xowuerybgvcrvxm.jpeg" alt="Werner Vogels Keynote - Non-functional Requirements"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the photo I took from Werner Vogels Keynote. Security is one of the non-functional requirements, it's not a feature we can choose, it's about coverage.&lt;/p&gt;

&lt;p&gt;I always find it challenging to maintain the security posture within an AWS Organization, there are so many accounts and regions to take care of.&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://aws.amazon.com/blogs/security/introducing-new-central-configuration-capabilities-in-aws-security-hub/" rel="noopener noreferrer"&gt;AWS Security Hub central configuration&lt;/a&gt;, we can now configure security controls across accounts, across regions, all in the same place.&lt;/p&gt;

&lt;p&gt;What I love to see in the future is the same feature in Amazon Inspector, GuardDuty, and AWS Config.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS Security Hub custom control parameters
&lt;/h3&gt;

&lt;p&gt;It's Security Hub again. The &lt;a href="https://aws.amazon.com/about-aws/whats-new/2023/11/customize-security-controls-aws-security-hub/" rel="noopener noreferrer"&gt;custom control parameters&lt;/a&gt; is also a feature that I love to see.&lt;/p&gt;

&lt;p&gt;Before this, all Security Hub controls were hard-coded and mostly followed industry standards like CIS, PCI-DSS, and NIST 800-53. &lt;/p&gt;

&lt;p&gt;However, most standards only outline the minimum security requirements, and many organizations want to do better. E.g., the &lt;a href="https://docs.aws.amazon.com/securityhub/latest/userguide/iam-controls.html#iam-7" rel="noopener noreferrer"&gt;IAM user password policy&lt;/a&gt; is set to a minimum of 8 characters because of the NIST 800-53 standard. But I think most organizations would like their employees to use a longer password.&lt;/p&gt;

&lt;p&gt;Now, we can customize the control to check if all the AWS accounts meet the stronger password policy that we set.&lt;/p&gt;

&lt;h3&gt;
  
  
  Amazon GuardDuty ECS Runtime Monitoring
&lt;/h3&gt;

&lt;p&gt;The EKS runtime monitoring has already been available since early this year. This time, it's &lt;a href="https://aws.amazon.com/blogs/aws/introducing-amazon-guardduty-ecs-runtime-monitoring-including-aws-fargate/" rel="noopener noreferrer"&gt;expanded to ECS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Many companies don't have the talent to set up threat detection systems themselves, nor the skill to use Kubernetes. Having GuardDuty monitor the ECS workloads would be a nice feature to increase their monitoring coverage.&lt;/p&gt;

&lt;p&gt;Besides this, the runtime monitoring for EC2 is also in preview now!&lt;/p&gt;

&lt;h3&gt;
  
  
  Amazon Inspector agentless vulnerability assessments
&lt;/h3&gt;

&lt;p&gt;Historically, if we want Amazon Inspector to scan the EC2 instances for software vulnerability, we need to install an SSM agent into it. The agent also uses some of the instance's resources to perform the scanning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/about-aws/whats-new/2023/11/amazon-inspector-agentless-assessments-ec2-preview/" rel="noopener noreferrer"&gt;Agentless scanning&lt;/a&gt; allows Amazon Inspector to scan the instances without impacting the running instance.&lt;/p&gt;

&lt;p&gt;This is not a new feature and has been offered by several 3rd party cloud security vendors. But having an AWS-native tool to do it makes it more accessible to customers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Still good ones, but just ... disappointed
&lt;/h2&gt;

&lt;h3&gt;
  
  
  AWS Config periodic recording
&lt;/h3&gt;

&lt;p&gt;The high cost has always been my major complaint to AWS Config. Last week, when AWS announced &lt;a href="https://aws.amazon.com/about-aws/whats-new/2023/11/aws-config-periodic-recording/" rel="noopener noreferrer"&gt;AWS Config periodic recording&lt;/a&gt;, I thought it would alleviate some of our pain. But after digging deep into the details, I found it probably won't.&lt;/p&gt;

&lt;p&gt;First, most of the cost incurred by AWS Config is from the amount of resources we have in the account, not the frequency of changes. So, having a lower recording frequency doesn't really help reduce the cost.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7j3beu8t5nhf94lpxjt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7j3beu8t5nhf94lpxjt.png" alt="AWS Config recording price"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Second, the price of every periodic recording is 4x higher than continuous recording. So, if the average change frequency of your resources is at a certain level, periodic recording can cost you even more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Amazon S3 Access Grants
&lt;/h3&gt;

&lt;p&gt;I am having issues granting data access through AWS IAM Identity Center (i.e. AWS SSO). The problem is that permission can only be assigned to &lt;a href="https://docs.aws.amazon.com/singlesignon/latest/userguide/permissionsetsconcept.html" rel="noopener noreferrer"&gt;Permission Set&lt;/a&gt;, and the more granular I want the data access control to be, the more Permission Set I will be creating.&lt;/p&gt;

&lt;p&gt;When I saw &lt;a href="https://aws.amazon.com/blogs/storage/scaling-data-access-with-amazon-s3-access-grants/" rel="noopener noreferrer"&gt;Amazon S3 Access Grants&lt;/a&gt; announcement last week, I thought it would be my savior.&lt;/p&gt;

&lt;p&gt;However, after a few trials, I discovered it's quite difficult to set up.&lt;/p&gt;

&lt;p&gt;First, we need to create an app in AWS IAM Identity Center to perform some token exchanges and then assume a temporary role to further assume the S3 grant that finally gives you access to the data. (Doc is &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants-directory-ids.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Second, all these steps are unavailable in the console, so I'll need my data analysts to do all the complex CLI commands to get the data.&lt;/p&gt;

&lt;p&gt;This is a good feature on access control, but it's just too difficult to use.&lt;/p&gt;

&lt;h2&gt;
  
  
  GenAI
&lt;/h2&gt;

&lt;p&gt;GenAI is cool. It's the focus this year. But I think we are still uncertain about how it would relate to cybersecurity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Guardrails for Amazon Bedrock
&lt;/h3&gt;

&lt;p&gt;With &lt;a href="https://aws.amazon.com/blogs/aws/guardrails-for-amazon-bedrock-helps-implement-safeguards-customized-to-your-use-cases-and-responsible-ai-policies-preview/" rel="noopener noreferrer"&gt;Guardrails for Amazon Bedrock&lt;/a&gt;, we can set policies to restrict our Bedrock model from using certain topic or contents. We can also use it to redact PII.&lt;/p&gt;

&lt;p&gt;I would love to try out how accurate and robust it is. And how it compares to ChatGPT against all the bypass tricks out on the Internet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Responsible AI - Amazon Titan image watermark
&lt;/h3&gt;

&lt;p&gt;Last week, AWS announced a new foundation model, &lt;a href="https://aws.amazon.com/blogs/aws/amazon-titan-image-generator-multimodal-embeddings-and-text-models-are-now-available-in-amazon-bedrock/" rel="noopener noreferrer"&gt;AWS Titan Image Generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;AWS claimed that all images generated by this model will have an invisible watermark on them. And we can use it to detect if AI generates that image. It is a great feature to help fight against fake information.&lt;/p&gt;

&lt;p&gt;However, to date, I still can't find any details on how we can verify a given image, and how the watermark can withstand image distortion.&lt;/p&gt;

&lt;h3&gt;
  
  
  GenAI help cybersecurity
&lt;/h3&gt;

&lt;p&gt;There were many announcements last week on GenAI integrated with different services, like &lt;a href="https://aws.amazon.com/about-aws/whats-new/2023/11/amazon-cloudwatch-ai-powered-natural-language-query-generation-preview/" rel="noopener noreferrer"&gt;CloudWatch log query generation&lt;/a&gt;, &lt;a href="https://aws.amazon.com/about-aws/whats-new/2023/11/aws-config-generative-ai-powered-natural-language-querying-preview/" rel="noopener noreferrer"&gt;AWS Config query generation&lt;/a&gt;. I think these capabilities lower the bar of being a security operator on AWS. With more help from GenAI, we no longer need all the engineers to know different query languages to investigate security incidents. With Amazon Q, we can now easily find out what security controls we can or cannot do on AWS without digging into the documents.&lt;/p&gt;

&lt;p&gt;But still, I would love to see how AWS can use GenAI to improve cloud security in a more proactive way.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awsreinvent</category>
      <category>cloudsecurity</category>
    </item>
    <item>
      <title>AWS Nitro Enclaves Ecosystem (3) - Anjuna</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Sat, 29 Jul 2023 14:06:00 +0000</pubDate>
      <link>https://forem.com/aws-builders/aws-nitro-enclaves-ecosystem-3-anjuna-52og</link>
      <guid>https://forem.com/aws-builders/aws-nitro-enclaves-ecosystem-3-anjuna-52og</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Background&lt;br&gt;
 2. What is Anjuna&lt;br&gt;
       2.1. Tools as a Service&lt;br&gt;
 3. Features&lt;br&gt;
       3.2. Network Proxy&lt;br&gt;
       3.3. More handy tools - Secret Storing, Persistent Storage&lt;br&gt;
 4. Most Powerful Feature - Kubernetes plugin&lt;br&gt;
 5. Data Privacy&lt;br&gt;
       5.4. Operate in Private Network&lt;br&gt;
       5.5. Licensing Model&lt;br&gt;
 6. Final Thought&lt;br&gt;
       6.6. Trust Model&lt;br&gt;
       6.7. Target Audience&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;After my last &lt;a href="https://dev.to/aws-builders/aws-nitro-enclaves-ecosystem-2-evervault-48pm"&gt;post on Evervault&lt;/a&gt; was published, I didn't have time to try out other AWS Nitro Enclaves service providers. But luckily, Anjuna, which is also on my list to review, reached out to me and offered a free trial for me to review its Nitro enclaves offering.&lt;br&gt;&lt;br&gt;
So in this blog post, I will talk about my takes.&lt;br&gt;&lt;br&gt;
&lt;em&gt;If you are unfamiliar with AWS Nitro Enclaves, please read these AWS documents first. Otherwise, you may find it challenging to understand the rest of this post: &lt;a href="https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html" rel="noopener noreferrer"&gt;What is AWS Nitro Enclaves?&lt;/a&gt; / &lt;a href="https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave-concepts.html" rel="noopener noreferrer"&gt;Nitro Enclaves concepts&lt;/a&gt;&lt;/em&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  What is Anjuna
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.anjuna.io/" rel="noopener noreferrer"&gt;Anjuna Security&lt;/a&gt; is a company offering a software platform that automates the creation of confidential computing environments in the public cloud. Besides AWS Nitro Enclaves, they also support other cloud platforms (e.g., Azure, GCP) based on various hardware chipsets (e.g., Intel SGX, AMD SEV).  &lt;/p&gt;

&lt;h3&gt;
  
  
  Tools as a Service
&lt;/h3&gt;

&lt;p&gt;My initial expectation of Anjuna was that it would be a cloud service integrated with my AWS account through permission grants, a common approach of cloud service providers.  &lt;/p&gt;

&lt;p&gt;However, Anjuna doesn't go on this path. Instead, they provide a complete software platform to customers, helping them build and run their applications on AWS Nitro Enclaves.  &lt;/p&gt;

&lt;p&gt;During the process, no communication is needed between the workloads and Anjuna. With the tools downloaded upfront, customers can even build and deploy the application in a private VPC without Internet access.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;p&gt;The Anjuna Nitro Enclaves toolset consists of several useful tools to help developers build enclave applications.  &lt;/p&gt;

&lt;p&gt;Most of the tools act as the replacement for commonly used tools like docker, nitro-cli. The magic behind it is that when you run the command, the tools will embed some Anjuna-built runtime or services alongside your app and help achieve some tasks.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Diagram from Anjuna&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdocs.anjuna.io%2Fnitro%2Flatest%2F_images%2Fnitro-default-anjuna-combined.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdocs.anjuna.io%2Fnitro%2Flatest%2F_images%2Fnitro-default-anjuna-combined.png" alt="Diagram from Anjuna"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h3&gt;
  
  
  Network Proxy
&lt;/h3&gt;

&lt;p&gt;Without Anjuna, we need to create proxies in both the parent EC2 instance and the enclave runtime to forward traffic between them (See my &lt;a href="https://dev.to/aws-builders/running-python-app-on-aws-nitro-enclaves-3lhp"&gt;example&lt;/a&gt; in another post)  &lt;/p&gt;

&lt;p&gt;Instead of using AWS-provided &lt;code&gt;nitro-cli&lt;/code&gt;, we can use &lt;code&gt;anjuna-nitro-cli build-enclave&lt;/code&gt; to build the enclave image. The tool embeds the Anjuna Nitro Runtime into the image. This customized runtime provides more than just a network proxy on the enclave side. It also provides the proxy service for other functions I’ll discuss later.  &lt;/p&gt;

&lt;p&gt;Before running the enclave app, we need to run the command &lt;code&gt;anjuna-nitro-netd-parent --enclave-name &amp;lt;enclave_name&amp;gt; --daemonize&lt;/code&gt; to start the network proxy on the parent instance side.   &lt;/p&gt;

&lt;p&gt;By running two commands, we are ready to run an enclave app with network connections, a convenient experience for software developers.  &lt;/p&gt;

&lt;h3&gt;
  
  
  More handy tools - Secret Storing, Persistent Storage
&lt;/h3&gt;

&lt;p&gt;AWS KMS is one of the only 2 AWS services with native support on AWS Nitro Enclaves. When it comes to storage, developers need to be creative with their solutions.  &lt;/p&gt;

&lt;p&gt;Anjuna provides two solutions to it. The 1st one is secret storing, which utilizes S3 as storage and KMS as an encryption service.  &lt;/p&gt;

&lt;p&gt;The tool &lt;code&gt;anjuna-nitro-encrypt&lt;/code&gt; uses your AWS KMS key to encrypt the secret and upload it to an S3 bucket you specified.  &lt;/p&gt;

&lt;p&gt;When running the enclave app, we can specify the location of the encrypted file in the enclave config file. The Anjuna runtime in the enclave will help download, decrypt it with AWS KMS, and provide the secret to the app runtime.  &lt;/p&gt;

&lt;p&gt;Anjuna also provides seamless persistent block storage on AWS Nitro Enclaves. With a daemon running on the parent instance and the mount point configured in the enclave config file, the Anjuna Nitro tool can mount a block storage from the enclave runtime to a file on the parent instance.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Most Powerful Feature - Kubernetes plugin
&lt;/h2&gt;

&lt;p&gt;After discussing some handy tools, I need to spare another section on one of the most powerful tools, the Kubernetes plugin.  &lt;/p&gt;

&lt;p&gt;All the tools I have mentioned make deploying enclave applications easy, but just for one instance. When it comes to large-scale application deployment, Kubernetes is the most popular way to go, and Anjuna takes AWS Nitro Enclaves into this area.  &lt;/p&gt;

&lt;p&gt;Like previously mentioned tools, the Anjuna Nitro Kubernetes toolset embeds proxy into your workloads. But in this case, besides the Anjuna runtime (they call it &lt;strong&gt;Anjuna Nitro Launcher&lt;/strong&gt;), there are two additional Kubernetes resources – &lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook" rel="noopener noreferrer"&gt;MutatingWebhookConfiguration&lt;/a&gt;, &lt;a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins/" rel="noopener noreferrer"&gt;DevicePlugin&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F49o6eu8wyf2z4s31kpwf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F49o6eu8wyf2z4s31kpwf.jpg" alt="Anjuna Nitro Kubernetes toolset"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;We only need to add an annotation to the pod definition to deploy an application into the enclave. But under the hood, there are a series of events happening.  &lt;/p&gt;

&lt;p&gt;First, the Anjuna Nitro Webhook intercepts the request and modifies it. The two main changes are to embed the app image into the Anjuna Nitro Launcher runtime, which will provide services to the enclave app. Another main change is to specify the enclave requirement of the pod inside the &lt;code&gt;resources&lt;/code&gt; section.  &lt;/p&gt;

&lt;p&gt;Anjuna Device Manager is registered as a &lt;a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins/" rel="noopener noreferrer"&gt;device plugin&lt;/a&gt; of the Kubernetes cluster, so when a pod has an enclave requirement, it can assign it to the Nitro enclave through interaction with the Nitro Enclaves kernel API (i.e. &lt;code&gt;/dev/nitro_enclaves&lt;/code&gt;)  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg1axiteh7qr5gmyxq8yf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg1axiteh7qr5gmyxq8yf.png" alt="Anjuna Nitro Webhook modify pod definition"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fblhrm95699cfyr7r1p6c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fblhrm95699cfyr7r1p6c.png" alt="Anjuna Device Manager"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;This is a standard approach to customizing Kubernetes clusters. But with all these tweaks, the Anjuna Nitro Kubernetes toolset helps us deploy enclave applications in a scalable way.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Data Privacy
&lt;/h2&gt;

&lt;p&gt;Enclave applications usually process sensitive data, so privacy is the most critical concern.  &lt;/p&gt;

&lt;p&gt;With the Anjuna tool binary running inside the same enclave as the application, we have little to do to prevent it from accessing the data. But unlike other cloud services, Anjuna Nitro tools don’t require any communication between customers’ workloads and Anjuna’s servers. This opens up an option for customers to use Anjuna services without the risk of data exposure.   &lt;/p&gt;

&lt;h3&gt;
  
  
  Operate in Private Network
&lt;/h3&gt;

&lt;p&gt;Although the official documentation doesn’t emphasize, we can actually use Anjuna tools in a private network.  &lt;/p&gt;

&lt;p&gt;During my review, I tried to build a private VPC and run Anjuna inside, so here’s the result.  &lt;/p&gt;

&lt;p&gt;Firstly, I downloaded the Anjuna tools and the necessary container images into my EC2 instance.  &lt;/p&gt;

&lt;p&gt;Then, I created the VPC endpoints necessary for me to access the instance via AWS SSM.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Create VPC endpoints for SSM access&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6wxu9ouauiylbe6otrm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6wxu9ouauiylbe6otrm.png" alt="Create VPC endpoints for SSM access"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;And then, I restricted the instance security group outbound traffic to the VPC endpoints only.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Restrict instance access to the Internet&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04uf2tirz1u7owwf4xhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04uf2tirz1u7owwf4xhv.png" alt="Restrict instance access to the Internet"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;Since then, my EC2 instance has no access to the Internet. But under this environment, I can still use Anjuna tools to run the enclave application.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Anjuna tools can run without Internet&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fif1ufrq7absrii1h1upo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fif1ufrq7absrii1h1upo.png" alt="Anjuna tools can run without Internet"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;Another fun fact is that I tried building a self-managed Kubernetes cluster without using EKS and put it in a private subnet without internet access. The Anjuna Nitro Kubernetes toolset can still run correctly.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Licensing Model
&lt;/h3&gt;

&lt;p&gt;With Anjuna software running entirely offline, the license to customers is only checked locally. I think this is a carefully considered decision by Anjuna.   &lt;/p&gt;

&lt;p&gt;Given the focus on privacy by Anjuna's customers, it would have been challenging to accept tools running inside a sensitive workload sending data out, unless Anjuna could have proven they had no access to customers' data. But this would have required Anjuna to open source their tools, which doesn’t seem to fit their business model.   &lt;/p&gt;

&lt;p&gt;This license model works for Anjuna’s customers, as they provide not just the tools but also customer support.   &lt;/p&gt;

&lt;p&gt;They are also planning on transparent metric collection from customers' workloads, so Anjuna can better understand customers' usage, and the customers can also see what data is sent to Anjuna.   &lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Trust Model
&lt;/h3&gt;

&lt;p&gt;Enclave applications usually have access to sensitive data, so the users always pay attention to who has potential access to the data.  &lt;/p&gt;

&lt;p&gt;Most of the Nitro Enclaves use cases fall into 3 categories:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Building their own enclave applications (e.g., Dashlane)
&lt;/li&gt;
&lt;li&gt;Completely open-source (e.g., EdgeBit Enclaver)
&lt;/li&gt;
&lt;li&gt;Providing managed service to customers (e.g., Evervault, Oblivious AI)
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the first 2 cases, we don’t trust anyone and need complete control or visibility of the application source code. The last case is where we trust the vendors and use their service to minimize data exposure.  &lt;/p&gt;

&lt;p&gt;Anjuna is sitting in between them, which we trust Anjuna that we are installing their tools into the enclave without reviewing the source code. But we do not entirely trust it, so we may want to ensure no data is sent to them from our workloads.  &lt;/p&gt;

&lt;p&gt;This makes me think that as a Security Engineer, I always face the question between build and buy. Sometimes, I need to ask myself: Is this SOC2 or ISO 27001 certificate trustworthy? Can I trust the vendors that they can safeguard our data? Especially when I see many remarks and accepted risks in the audit reports.  &lt;/p&gt;

&lt;p&gt;But even with these doubts, we still need to choose the vendor because building our own solution is simply too expensive.  &lt;/p&gt;

&lt;p&gt;Having a choice to host the application completely in our environment is definitely a plus in these trade-offs. And I think Anjuna is smartly positioning its services here: Not disclosing the tool logic, but you are free to decide where to deploy.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Target Audience
&lt;/h3&gt;

&lt;p&gt;The current licensing model of Anjuna and the technical skills required to use the tools (Especially the knowledge of deploying resources on AWS) are suitable for enterprises whose primary focus is not developing software.  &lt;/p&gt;

&lt;p&gt;On the one hand, those companies have enough technical personnel to deploy the applications. On the other hand, they don’t have enough resources or incentives to hire and train engineers specifically on enclave technology.  &lt;/p&gt;

&lt;p&gt;For Anjuna itself, managing those customers is also easier because they can build close relationships with a small number of big companies. Anjuna can even provide special arrangements for their most important customers to audit the tools source code.  &lt;/p&gt;

&lt;p&gt;I am interested in what direction Anjuna will go in the future. Will they explore other business models to expand the customer base? How will they make their tools much more accessible to customers with fewer technical skills without compromising the risk of customers’ data?  &lt;/p&gt;

&lt;p&gt;With more types of service offerings, more public awareness of enclave technology, and the pros and cons of different options, I believe there will be more adoption in the future. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>ec2</category>
      <category>nitroenclaves</category>
    </item>
    <item>
      <title>AWS Nitro Enclaves Ecosystem (2) - Evervault</title>
      <dc:creator>Richard Fan</dc:creator>
      <pubDate>Thu, 09 Feb 2023 16:26:06 +0000</pubDate>
      <link>https://forem.com/aws-builders/aws-nitro-enclaves-ecosystem-2-evervault-48pm</link>
      <guid>https://forem.com/aws-builders/aws-nitro-enclaves-ecosystem-2-evervault-48pm</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt; 1. Background&lt;br&gt;
 2. What is Evervault&lt;br&gt;
       2.1. Encryption service&lt;br&gt;
       2.2. Runtime provisioning&lt;br&gt;
             a. Evervault Functions&lt;br&gt;
             b. Evervault Cages&lt;br&gt;
 3. Deep dive&lt;br&gt;
       3.3. Less infrastructure overhead&lt;br&gt;
       3.4. TLS Attestation&lt;br&gt;
       3.5. Unknown sidecar&lt;br&gt;
       3.6. Insufficient access control&lt;br&gt;
 4. My thought&lt;br&gt;
 5. Final thought&lt;/p&gt;
&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;If you haven't read my previous post, please read &lt;a href="https://dev.to/aws-builders/aws-nitro-enclaves-ecosystem-1-chain-of-trust-10ia"&gt;AWS Nitro Enclaves Ecosystem (1) - Chain of trust&lt;/a&gt; on how I see services built on top of AWS Nitro Enclaves and the importance of Attestation Document.&lt;/p&gt;

&lt;p&gt;This time, I'm going to talk about my thought on Evervault.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Evervault
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://evervault.com/" rel="noopener noreferrer"&gt;Evervault&lt;/a&gt; provides transparent encryption using relay webhooks.&lt;/p&gt;
&lt;h3&gt;
  
  
  Encryption service
&lt;/h3&gt;

&lt;p&gt;The idea is that before sensitive data goes into the system, you can route the traffic through Evervault &lt;a href="https://docs.evervault.com/products/inbound-relay" rel="noopener noreferrer"&gt;Inbound Relay&lt;/a&gt; to encrypt it so that the system can only get the encrypted data.&lt;/p&gt;

&lt;p&gt;To use the encrypted data, Evervault provides &lt;a href="https://docs.evervault.com/products/outbound-relay" rel="noopener noreferrer"&gt;Outbound Relay&lt;/a&gt; to decrypt the data before sending it to the external components.&lt;/p&gt;

&lt;p&gt;Using it, developers can build applications that handle sensitive data without worrying about encryption or changing the code to protect it.&lt;/p&gt;

&lt;p&gt;Evervault states that the encryption is performed by &lt;a href="https://docs.evervault.com/security/evervault-encryption" rel="noopener noreferrer"&gt;Evervault Encryption Engine (E3)&lt;/a&gt;, which is running on Nitro Enclaves. However, there is no way for us to tell whether it's true. There is no independent audit available as well.&lt;/p&gt;
&lt;h3&gt;
  
  
  Runtime provisioning
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Evervault Functions
&lt;/h4&gt;

&lt;p&gt;Besides simply encrypting data, Evervault also provides the environment for developers to run simple functions on sensitive data.&lt;/p&gt;

&lt;p&gt;The current offering is &lt;a href="https://docs.evervault.com/products/functions" rel="noopener noreferrer"&gt;Evervault Functions&lt;/a&gt;, in which you can invoke your custom Python or Node.js application with the encrypted data. Your application will be given decrypted data as parameters so you can perform your business logic on it.&lt;/p&gt;

&lt;p&gt;The example Evervault provides is to &lt;a href="https://docs.evervault.com/guides/validate-phone-numbers" rel="noopener noreferrer"&gt;validate encrypted phone number&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Evervault Cages
&lt;/h4&gt;

&lt;p&gt;Evervault Functions is not running on Nitro Enclaves, so I will not discuss it in this blog post. But Evervault has a beta offering called &lt;a href="https://docs.evervault.com/products/cages" rel="noopener noreferrer"&gt;Evervault Cages&lt;/a&gt; which provides a similar feature on Nitro Enclaves. In this blog post, I will focus on it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Deep dive
&lt;/h2&gt;

&lt;p&gt;I tried Evervault Cages by following their &lt;a href="https://docs.evervault.com/products/cages#getting-started" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, as well as the help from the Evervault team to understand how it works.&lt;/p&gt;

&lt;p&gt;This session is about the key points which are worth considering.&lt;/p&gt;
&lt;h3&gt;
  
  
  Less infrastructure overhead
&lt;/h3&gt;

&lt;p&gt;Using Cages CLI, you can quickly build your docker application and deploy it into Nitro Enclave. You don't need to provision EC2 instances or configure Nitro Enclaves. Evervault provides the infrastructure in their AWS account for you during deployment.&lt;/p&gt;

&lt;p&gt;You also don't need to handle external traffic, as Evervault will handle it for you. The Cage application endpoint will be forwarded to the exposed port of your enclave application. Evervault can also forward egress traffic from the enclave to the Internet.&lt;/p&gt;
&lt;h3&gt;
  
  
  TLS Attestation
&lt;/h3&gt;

&lt;p&gt;Another feature Evervault Cages provides is &lt;a href="https://docs.evervault.com/products/cages#tls-attestation" rel="noopener noreferrer"&gt;TLS Attestation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When TLS termination is enabled in your Cage application, the attestation document of the Nitro Enclave will be embedded inside the Cage endpoint TLS certificate.&lt;/p&gt;

&lt;p&gt;According to the documentation, you can only use Evervault SDK or CLI to validate the embedded Attestation document. The tools use an undocumented API to retrieve the attestation. We can use the same API to validate the attestation document ourselves.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xrzia58918pn3c65h2a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xrzia58918pn3c65h2a.png" alt="Connect to the Cage endpoint with a nonce" width="800" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fho0z2uix2of8ua80vybq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fho0z2uix2of8ua80vybq.png" alt="Attestation document is embedded in the TLS certificate" width="800" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When connecting to the Cage application endpoint &lt;code&gt;&amp;lt;cage_name&amp;gt;.&amp;lt;cage_id&amp;gt;.cages.evervault.com&lt;/code&gt; (or &lt;code&gt;&amp;lt;nonce&amp;gt;.attest.&amp;lt;cage_name&amp;gt;.&amp;lt;cage_id&amp;gt;.cages.evervault.com&lt;/code&gt; if you want to use nonce on the attestation), the Evervault-signed TLS cert will contain a Nitro Enclave attestation document in the &lt;strong&gt;Subject Alternative Name (SAN)&lt;/strong&gt; section, in hex code format.&lt;/p&gt;

&lt;p&gt;Besides using TLS Attestation, Cage environment also provides an &lt;a href="https://docs.evervault.com/products/cages#attestation-document" rel="noopener noreferrer"&gt;internal API&lt;/a&gt; &lt;code&gt;http://127.0.0.1:9999/attestation-doc&lt;/code&gt; for developers to retrieve attestation document within the enclave.&lt;/p&gt;

&lt;p&gt;These two features help application developers use attestation documents to validate enclave identity without writing their code to retrieve attestation documents.&lt;/p&gt;
&lt;h3&gt;
  
  
  Unknown sidecar
&lt;/h3&gt;

&lt;p&gt;To achieve features like egress proxy, TLS Attestation, etc. Evervault Cages installs a proxy sidecar, which they call it &lt;strong&gt;Data Plane&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzw0xxfa5lxd2e8jqwcpk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzw0xxfa5lxd2e8jqwcpk.png" alt="Comparison between original Dockerfile and the version ev-cage has modified" width="772" height="681"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we run the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ev-cage build &lt;span class="nt"&gt;--write&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ev-cage&lt;/code&gt; will modify our original &lt;code&gt;Dockerfile&lt;/code&gt;, adding two files (One is the runtime dependency, the other one is the sidecar) into it.&lt;/p&gt;

&lt;p&gt;As of the time of writing, there is still no source code of the &lt;strong&gt;Data Plane&lt;/strong&gt; sidecar publicly available. So when using Evervault Cages, we need to keep in mind that an unknown binary is running along with your application in the enclave.&lt;/p&gt;

&lt;p&gt;There is a risk of Evervault doing bad things on the sidecar, or there are vulnerabilities on it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Insufficient access control
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;API key&lt;/strong&gt; is the only &lt;a href="https://docs.evervault.com/sdks/cli#authentication" rel="noopener noreferrer"&gt;authentication&lt;/a&gt; method Evervault provides for programmatic access.&lt;/p&gt;

&lt;p&gt;In a simple platform, this is not an issue. But if I use Nitro Enclaves (or Evervault Cages in this case), I would expect additional data protection.&lt;/p&gt;

&lt;p&gt;The issues I can see are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lack of permission separation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each Evervault app only has one API key, which can be used across different services (i.e. Relay, Functions, Cages).&lt;/p&gt;

&lt;p&gt;An API key used by Cages can also be used by Functions, so we cannot guarantee an encrypted data can only be decrypted by Cage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lack of attestation document support&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://docs.evervault.com/products/cages#decrypt" rel="noopener noreferrer"&gt;decryption API&lt;/a&gt; only takes the API key as the sole authentication method. There is no control similar to AWS KMS &lt;a href="https://docs.aws.amazon.com/kms/latest/developerguide/conditions-nitro-enclaves.html" rel="noopener noreferrer"&gt;key policy&lt;/a&gt;, where we can specify &lt;em&gt;"only this enclave image can decrypt my secret"&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Image if I have a system which handles both phone no. and credit card no. I want to validate phone no. on Evervault Functions because it's not very sensitive.&lt;/p&gt;

&lt;p&gt;But I want to validate the credit card no. on Cages because it's more sensitive than phone no.&lt;/p&gt;

&lt;p&gt;In this case, I have no way to protect credit card no. because the &lt;em&gt;phone no. validation developers&lt;/em&gt; can decrypt the credit card no. using their API key (because they are the same).&lt;/p&gt;

&lt;p&gt;Even though API keys are separated, the &lt;em&gt;credit card no. validation developers&lt;/em&gt; can also decrypt the credit card no. because they can write a rogue app (e.g. reverse shell) and deploy it to Cages, then use the decrypt API. Since there is no attestation authentication on the API, we cannot specify which enclave image can decrypt the secret.&lt;/p&gt;

&lt;h2&gt;
  
  
  My thought
&lt;/h2&gt;

&lt;p&gt;The idea of Evervault is good, making data protection as easy as possible. Abstracting protecting data-in-use away from developers using Functions and Cages is a boost on adoption.&lt;/p&gt;

&lt;p&gt;However, the current state of Evervault Cages is still a long way to go. I would say Cages is as good as the current Functions offering in terms of security and privacy, but there is no significant extra benefit on top of it.&lt;/p&gt;

&lt;p&gt;I would suggest the following if Evervault is targeting first-time users who are not familiar with confidential computing and want a quick start:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Provides permission control for the API key so users can have more control of data on different privacy levels.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Evervault response: Evervault is now working on refining the scopes for API Keys, specifically for decoupling Cages from the surrounding products&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If Evervault is to target more advanced users who treat sensitive data seriously, they can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open source the &lt;strong&gt;Data Plane&lt;/strong&gt; sidecar so users can review its security.&lt;/p&gt;

&lt;p&gt;Alternatively, if Evervault wants to avoid publishing the source code, they can find a reputable 3rd-party audit. Or open source a lightweight version of the sidecar with fewer functions, so users can choose to minimise their risk by using it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Evervault response: Evervault is now undergoing a 3rd Party audit for Cages. Open sourcing is also in their roadmap.&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Provides attestation document authentication so users can specify which enclave image can decrypt specific data.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Evervault response: Evervault is now working on the Cages auth for encryption/decryption to include an attestation step&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Final thought
&lt;/h2&gt;

&lt;p&gt;To be fair, Evervault Cages is a new release, and it's not expected to be perfect now. Evervault team has done a great job of democratising Nitro Enclaves’ use. They are open to feedback as well.&lt;/p&gt;

&lt;p&gt;I suggest you try it out and have a taste of how confidential computing works.&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
  </channel>
</rss>
