<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hessam P on Medium]]></title>
        <description><![CDATA[Stories by Hessam P on Medium]]></description>
        <link>https://medium.com/@hessam.p?source=rss-6d2e4930aa25------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QmfkloD2VBS6VPAFznqgdA.jpeg</url>
            <title>Stories by Hessam P on Medium</title>
            <link>https://medium.com/@hessam.p?source=rss-6d2e4930aa25------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:13:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hessam.p/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Python Is Still the King of Modern AI: Lessons from X’s Recommendation Algorithm]]></title>
            <link>https://medium.com/@hessam.p/why-python-is-still-the-king-of-modern-ai-lessons-from-xs-recommendation-algorithm-011341a61ff0?source=rss-6d2e4930aa25------2</link>
            <guid isPermaLink="false">https://medium.com/p/011341a61ff0</guid>
            <dc:creator><![CDATA[Hessam P]]></dc:creator>
            <pubDate>Fri, 15 May 2026 19:36:17 GMT</pubDate>
            <atom:updated>2026-05-15T19:36:17.625Z</atom:updated>
            <content:encoded><![CDATA[<p>Today X has published its “For You” Algorithm and And yes the backend engineering is impressive.</p><p>But if you look deeper into the repository, something else becomes obvious:</p><p>The actual intelligence of the system, the models deciding what billions of users see, is still heavily driven by Python.</p><p>That’s the important takeaway.</p><p>Despite the rise of low-level systems languages, Python remains the dominant language for machine learning and large-scale AI systems. The X recommendation stack is a perfect example of why.</p><h3>Rust Moves the Data. Python Decides the Outcome.</h3><p>Modern recommendation systems are essentially split into two layers:</p><h3>Infrastructure Layer</h3><p>Responsible for:</p><ul><li>streaming data</li><li>handling concurrency</li><li>low-latency serving</li><li>memory safety</li><li>distributed processing</li></ul><p>This is where languages like Rust shine.</p><h3>Intelligence Layer</h3><p>Responsible for:</p><ul><li>model training</li><li>ranking logic</li><li>experimentation</li><li>feature engineering</li><li>prediction pipelines</li><li>ML orchestration</li></ul><p>This is where Python dominates.</p><p>The X algorithm demonstrates a hybrid architecture that many modern AI companies are converging toward:</p><ul><li>Rust for performance-critical infrastructure</li><li>Python for machine learning intelligence</li></ul><p>Not competition. Collaboration.</p><h3>1. The “Phoenix” Transformer: Python as the Brain</h3><p>One of the most fascinating parts of the repository is the transformer-based ranking system sometimes referred to as <em>Phoenix</em>.</p><p>The model doesn’t simply predict:</p><blockquote><em>“Will the user like this tweet?”</em></blockquote><p>Instead, it performs <strong>multi-task prediction</strong> across many engagement signals simultaneously.</p><p>The system estimates probabilities for actions like:</p><ul><li>Likes</li><li>Replies</li><li>Retweets</li><li>Profile clicks</li><li>Follows</li><li>Negative feedback</li><li>Even the probability of blocking the author</li></ul><p>This matters because recommendation systems are optimization engines.</p><p>A platform doesn’t want maximum clicks.<br> It wants maximum <em>valuable engagement</em> while minimizing toxic outcomes.</p><p>Python excels here because ML engineers can rapidly express:</p><ul><li>tensor operations</li><li>probabilistic models</li><li>training loops</li><li>feature transformations</li><li>experimentation pipelines</li></ul><p>with remarkably little code.</p><p>That developer velocity is still unmatched.</p><h3>2. Hash Embeddings: Scaling Without Exploding Memory</h3><p>Another elegant idea inside the system is the use of <strong>hash-based embeddings</strong>.</p><p>Traditional embedding systems often require enormous lookup tables:</p><ul><li>one vector per user</li><li>one vector per tweet</li><li>one vector per entity</li></ul><p>At X scale, that becomes incredibly expensive.</p><p>Instead, engineers use hashing techniques to map huge ID spaces into a fixed number of embedding buckets.</p><p>Conceptually:</p><p>h(x)=x mod Nh(x)=x\bmod Nh(x)=xmodN</p><p>Where:</p><ul><li>xxx is a user or content ID</li><li>NNN is a fixed embedding space size</li></ul><p>This dramatically reduces memory usage while maintaining acceptable accuracy.</p><p>And again, Python is the ideal experimentation environment for this type of innovation because:</p><ul><li>iteration speed is fast</li><li>ML tooling is mature</li><li>numerical libraries are world-class</li><li>debugging is simple</li></ul><p>The result:<br> A system capable of serving millions of users efficiently without requiring impossible amounts of RAM.</p><h3>3. The Heavy Ranker Pipeline</h3><p>The final feed ranking stage is often called the <strong>Heavy Ranker</strong>.</p><p>This is where the recommendation engine enriches raw content with contextual features before final scoring.</p><p>A simple post ID becomes hydrated with:</p><ul><li>author reputation</li><li>engagement history</li><li>relationship strength</li><li>user preferences</li><li>interaction recency</li><li>content quality signals</li></ul><p>Then the model evaluates all of it together.</p><p>This orchestration layer is where Python becomes incredibly powerful.</p><p>Libraries like:</p><ul><li>PyTorch</li><li>TensorFlow</li><li>Pydantic</li></ul><p>allow engineers to:</p><ul><li>validate schemas</li><li>experiment rapidly</li><li>ship new ranking logic safely</li><li>train and deploy models continuously</li></ul><p>In large-scale ML systems, maintainability matters just as much as raw speed.</p><p>Python remains exceptional at both.</p><h3>The Real Lesson: AI Systems Are Becoming Hybrid</h3><p>The X recommendation system highlights an important industry trend:</p><h3>The future is not “Python vs Rust.”</h3><p>It’s:</p><ul><li>Rust for infrastructure</li><li>Python for intelligence</li></ul><p>This pattern is increasingly common across modern AI companies because it combines:</p><ul><li>high performance</li><li>fast experimentation</li><li>operational safety</li><li>rapid ML iteration</li></ul><p>And that balance is incredibly difficult to beat.</p><h3>Why Python Still Wins in AI</h3><p>People often argue that Python is “too slow” for modern AI systems.</p><p>But that argument misunderstands where the bottlenecks actually are.</p><p>In machine learning:</p><ul><li>heavy numerical operations run in optimized C/CUDA kernels</li><li>GPUs do the tensor computation</li><li>distributed systems handle scaling</li></ul><p>Python acts as the orchestration layer.</p><p>And for orchestration, readability and ecosystem matter more than raw interpreter speed.</p><p>That’s why Python continues to dominate:</p><ul><li>research</li><li>experimentation</li><li>production ML pipelines</li><li>LLM development</li><li>recommendation systems</li></ul><p>including one of the most influential recommendation engines on Earth.</p><h3>Final Thoughts</h3><p>The X algorithm repository tells a bigger story than most people realized.</p><p>It’s not proof that Rust replaced Python.</p><p>It’s proof that modern AI systems require both:</p><ul><li>systems engineering excellence</li><li>machine learning flexibility</li></ul><p>Rust provides the performance.</p><p>Python provides the intelligence.</p><p>And for the foreseeable future, if you’re building advanced AI systems, there’s a very high chance Python is still at the center of them.</p><h3>What do you think?</h3><p>Will Python remain dominant in AI over the next decade, or will newer systems languages eventually take over parts of the ML stack?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=011341a61ff0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Secrets in Python Apps with HashiCorp Vault: A Practical Guide]]></title>
            <link>https://medium.com/@hessam.p/managing-secrets-in-python-apps-with-hashicorp-vault-a-practical-guide-d6e4039b4ce6?source=rss-6d2e4930aa25------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6e4039b4ce6</guid>
            <dc:creator><![CDATA[Hessam P]]></dc:creator>
            <pubDate>Thu, 07 May 2026 22:06:26 GMT</pubDate>
            <atom:updated>2026-05-07T22:06:26.168Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Stop hardcoding credentials. Here’s how to deploy Vault and connect it to your Python application — step by step.</em></p><p>If you’ve ever committed a database password to Git, copied an API key into a .env file and hoped for the best, or rotated a credential and spent the next hour hunting down everywhere it was hardcoded — this guide is for you.</p><p>HashiCorp Vault is a secrets management platform that gives you a single, audited, identity-based place to store and retrieve credentials. This tutorial walks you through deploying Vault (locally and in production) and wiring it up to your Python application using the hvac client library.</p><h3>What We’ll Cover</h3><ol><li>How Vault works (the mental model)</li><li>Running Vault locally with Docker</li><li>Storing and organizing secrets</li><li>Reading secrets from Python with hvac</li><li>Authentication methods (Token, AppRole, and AWS IAM)</li><li>Dynamic secrets — the killer feature</li><li>Production deployment checklist</li></ol><h3>1. The Mental Model: How Vault Works</h3><p>Before writing any code, it helps to understand Vault’s core abstractions.</p><p><strong>Secrets Engines</strong> are plugins that store, generate, or encrypt data. The most common are:</p><ul><li>kv (Key-Value) — stores static secrets like passwords and API keys</li><li>database — generates dynamic, short-lived database credentials on demand</li><li>aws — generates temporary AWS IAM credentials</li><li>pki — acts as a certificate authority</li></ul><p><strong>Auth Methods</strong> control how clients authenticate to Vault. Common options include tokens, AppRole (for applications), GitHub, Kubernetes, and AWS IAM.</p><p><strong>Policies</strong> are HCL documents that define what a given identity can read, write, or delete. They follow a path-based model: secret/data/myapp/* means &quot;everything under this path.&quot;</p><p><strong>Leases</strong> are the mechanism behind dynamic secrets. Every secret generated by Vault has a time-to-live (TTL). When the lease expires, the credential is automatically revoked.</p><p>The typical flow for a Python app looks like this:</p><pre>App starts → Authenticates to Vault → Receives token → Reads secret → Uses credential</pre><h3>2. Running Vault Locally with Docker</h3><p>The fastest way to get started is with the official Docker image in <strong>dev mode</strong> — a single-node, in-memory Vault that auto-initializes and auto-unseals.</p><blockquote><em>⚠️ Dev mode is for development only. Never use it in production. Data is not persisted.</em></blockquote><pre>docker run --rm --cap-add=IPC_LOCK \<br>  -e &#39;VAULT_DEV_ROOT_TOKEN_ID=dev-root-token&#39; \<br>  -e &#39;VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200&#39; \<br>  -p 8200:8200 \<br>  hashicorp/vault:latest</pre><p>Verify it’s running:</p><pre>export VAULT_ADDR=&#39;http://127.0.0.1:8200&#39;<br>export VAULT_TOKEN=&#39;dev-root-token&#39;</pre><pre># Using the Vault CLI (install separately or exec into the container)<br>vault status</pre><p>You should see Sealed: false — Vault is running and ready.</p><p>Alternatively, open the UI at <a href="http://localhost:8200/ui">http://localhost:8200/ui</a> and sign in with the token dev-root-token.</p><h3>3. Storing Secrets</h3><p>Vault’s KV (Key-Value) secrets engine is the most common starting point. In dev mode, a KV v2 engine is already mounted at secret/.</p><h3>Using the CLI</h3><pre># Write a secret<br>vault kv put secret/myapp/database \<br>  username=&quot;dbuser&quot; \<br>  password=&quot;s3cur3p@ss&quot; \<br>  host=&quot;db.internal:5432&quot;</pre><pre># Read it back<br>vault kv get secret/myapp/database</pre><h3>Using the HTTP API directly</h3><p>Every Vault operation is available as a REST API call. This is what the Python client wraps.</p><pre>curl -H &quot;X-Vault-Token: dev-root-token&quot; \<br>  http://127.0.0.1:8200/v1/secret/data/myapp/database</pre><h3>Organizing Secrets</h3><p>Think of the path as a filesystem. A clean convention for a Python web app might look like:</p><pre>secret/<br>├── myapp/<br>│   ├── database          # DB credentials<br>│   ├── redis             # Cache credentials<br>│   ├── third-party/<br>│   │   ├── stripe        # Payment API keys<br>│   │   └── sendgrid      # Email API keys<br>│   └── jwt               # JWT signing secrets</pre><h3>4. Reading Secrets from Python</h3><p>Install the official Python client:</p><pre>pip install hvac</pre><h3>Basic Connection and Secret Read</h3><pre>import hvac<br><br># Connect to Vault<br>client = hvac.Client(<br>    url=&#39;http://127.0.0.1:8200&#39;,<br>    token=&#39;dev-root-token&#39;  # Never hardcode in production - more on this below<br>)<br># Verify authentication<br>assert client.is_authenticated(), &quot;Vault authentication failed&quot;<br># Read a KV v2 secret<br>secret = client.secrets.kv.v2.read_secret_version(<br>    path=&#39;myapp/database&#39;,<br>    mount_point=&#39;secret&#39;<br>)<br># The actual data lives here<br>creds = secret[&#39;data&#39;][&#39;data&#39;]<br>print(creds[&#39;username&#39;])  # dbuser<br>print(creds[&#39;host&#39;])      # db.internal:5432</pre><h3>A Reusable Vault Client Class</h3><p>Rather than sprinkling hvac calls throughout your app, wrap it in a simple class:</p><pre>import hvac<br>import os<br>from functools import lru_cache<br><br><br>class VaultClient:<br>    def __init__(self):<br>        self._client = hvac.Client(<br>            url=os.environ[&#39;VAULT_ADDR&#39;],<br>            token=os.environ.get(&#39;VAULT_TOKEN&#39;)<br>        )<br>        if not self._client.is_authenticated():<br>            raise RuntimeError(&quot;Failed to authenticate with Vault&quot;)<br>    def get_secret(self, path: str, mount_point: str = &#39;secret&#39;) -&gt; dict:<br>        &quot;&quot;&quot;Read a KV v2 secret. Returns the data dict.&quot;&quot;&quot;<br>        response = self._client.secrets.kv.v2.read_secret_version(<br>            path=path,<br>            mount_point=mount_point<br>        )<br>        return response[&#39;data&#39;][&#39;data&#39;]<br>    def get_value(self, path: str, key: str, mount_point: str = &#39;secret&#39;) -&gt; str:<br>        &quot;&quot;&quot;Read a single value from a KV v2 secret.&quot;&quot;&quot;<br>        return self.get_secret(path, mount_point)[key]<br><br># Usage<br>vault = VaultClient()<br>db_password = vault.get_value(&#39;myapp/database&#39;, &#39;password&#39;)</pre><h3>Integration with SQLAlchemy</h3><pre>import sqlalchemy<br>from vault_client import VaultClient  # your wrapper above<br><br><br>def create_engine():<br>    vault = VaultClient()<br>    creds = vault.get_secret(&#39;myapp/database&#39;)<br>    db_url = (<br>        f&quot;postgresql://{creds[&#39;username&#39;]}:{creds[&#39;password&#39;]}&quot;<br>        f&quot;@{creds[&#39;host&#39;]}/{creds[&#39;dbname&#39;]}&quot;<br>    )<br>    return sqlalchemy.create_engine(db_url)<br><br>engine = create_engine()</pre><h3>Integration with requests (Third-Party APIs)</h3><pre>import requests<br>from vault_client import VaultClient<br><br><br>def get_stripe_client():<br>    vault = VaultClient()<br>    api_key = vault.get_value(&#39;myapp/third-party/stripe&#39;, &#39;secret_key&#39;)<br>    # Pass to your Stripe client<br>    import stripe<br>    stripe.api_key = api_key<br>    return stripe</pre><h3>5. Authentication Methods</h3><p>Using a hardcoded root token is fine for local development. In real deployments, you should use a proper auth method.</p><h3>AppRole — Recommended for Applications</h3><p>AppRole is designed for machine-to-machine authentication. Your app gets a role_id (like a username) and a secret_id (like a password), both of which it presents to Vault to receive a short-lived token.</p><p><strong>Set up AppRole in Vault:</strong></p><pre># Enable AppRole auth<br>vault auth enable approle</pre><pre># Create a policy for the app<br>vault policy write myapp-policy - &lt;&lt;EOF<br>path &quot;secret/data/myapp/*&quot; {<br>  capabilities = [&quot;read&quot;]<br>}<br>EOF</pre><pre># Create a role<br>vault write auth/approle/role/myapp \<br>  token_policies=&quot;myapp-policy&quot; \<br>  token_ttl=1h \<br>  token_max_ttl=4h</pre><pre># Fetch the role_id (not secret — this is static)<br>vault read auth/approle/role/myapp/role-id</pre><pre># Generate a secret_id (treat this like a password)<br>vault write -f auth/approle/role/myapp/secret-id</pre><p><strong>Authenticate from Python:</strong></p><pre>import hvac<br>import os<br><br><br>def get_vault_client() -&gt; hvac.Client:<br>    client = hvac.Client(url=os.environ[&#39;VAULT_ADDR&#39;])<br>    # Authenticate using AppRole<br>    response = client.auth.approle.login(<br>        role_id=os.environ[&#39;VAULT_ROLE_ID&#39;],<br>        secret_id=os.environ[&#39;VAULT_SECRET_ID&#39;]<br>    )<br>    # The client is now authenticated with a short-lived token<br>    assert client.is_authenticated()<br>    return client</pre><p>Inject VAULT_ROLE_ID and VAULT_SECRET_ID via your deployment environment (Kubernetes secrets, CI/CD secrets, etc.) — never into source code.</p><h3>AWS IAM Auth — For Apps Running on AWS</h3><p>If your Python app runs on an EC2 instance, ECS task, or Lambda with an IAM role, you can authenticate to Vault using that IAM identity — no secret_id needed.</p><pre># Enable AWS auth in Vault<br>vault auth enable aws</pre><pre># Configure with your AWS credentials<br>vault write auth/aws/config/client \<br>  access_key=$AWS_ACCESS_KEY_ID \<br>  secret_key=$AWS_SECRET_ACCESS_KEY</pre><pre># Create a role bound to an IAM role ARN<br>vault write auth/aws/role/myapp-role \<br>  auth_type=iam \<br>  bound_iam_principal_arn=&quot;arn:aws:iam::123456789:role/myapp-ec2-role&quot; \<br>  policies=&quot;myapp-policy&quot; \<br>  max_ttl=1h</pre><pre>import hvac<br>import boto3<br>import os<br><br><br>def get_vault_client_aws() -&gt; hvac.Client:<br>    client = hvac.Client(url=os.environ[&#39;VAULT_ADDR&#39;])<br>    # hvac handles the AWS IAM signing automatically<br>    client.auth.aws.iam_login(<br>        role=&#39;myapp-role&#39;<br>    )<br>    assert client.is_authenticated()<br>    return client</pre><h3>6. Dynamic Secrets — The Killer Feature</h3><p>Static secrets (KV store) are a huge improvement over .env files, but dynamic secrets take security to a completely different level.</p><p>Instead of storing a database password, you ask Vault to <strong>generate a brand new, unique credential</strong> valid for only a few minutes. When the TTL expires, Vault revokes the credential automatically. If a credential is leaked, it’s already dead.</p><h3>Setting Up Dynamic Database Secrets</h3><pre># Enable the database secrets engine<br>vault secrets enable database</pre><pre># Configure it for PostgreSQL<br>vault write database/config/myapp-db \<br>  plugin_name=postgresql-database-plugin \<br>  allowed_roles=&quot;myapp-role&quot; \<br>  connection_url=&quot;postgresql://{{username}}:{{password}}@db.internal:5432/mydb&quot; \<br>  username=&quot;vault-admin&quot; \<br>  password=&quot;vault-admin-password&quot;</pre><pre># Define a role with a SQL template for creating credentials<br>vault write database/roles/myapp-role \<br>  db_name=myapp-db \<br>  creation_statements=&quot;CREATE ROLE \&quot;{{name}}\&quot; WITH LOGIN PASSWORD &#39;{{password}}&#39; VALID UNTIL &#39;{{expiration}}&#39;; GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA public TO \&quot;{{name}}\&quot;;&quot; \<br>  default_ttl=&quot;1h&quot; \<br>  max_ttl=&quot;24h&quot;</pre><h3>Reading Dynamic Credentials from Python</h3><pre>import hvac<br>import sqlalchemy<br>import os<br><br><br>def get_dynamic_db_engine() -&gt; sqlalchemy.Engine:<br>    client = hvac.Client(<br>        url=os.environ[&#39;VAULT_ADDR&#39;],<br>        token=os.environ[&#39;VAULT_TOKEN&#39;]<br>    )<br>    # Vault generates a fresh credential on every call<br>    lease = client.secrets.database.generate_credentials(<br>        name=&#39;myapp-role&#39;<br>    )<br>    username = lease[&#39;data&#39;][&#39;username&#39;]<br>    password = lease[&#39;data&#39;][&#39;password&#39;]<br>    lease_id = lease[&#39;lease_id&#39;]<br>    lease_duration = lease[&#39;lease_duration&#39;]  # seconds<br>    print(f&quot;Got credential: {username} (expires in {lease_duration}s)&quot;)<br>    db_url = f&quot;postgresql://{username}:{password}@db.internal:5432/mydb&quot;<br>    return sqlalchemy.create_engine(<br>        db_url,<br>        pool_pre_ping=True,<br>        pool_recycle=int(lease_duration * 0.9)  # recycle before expiry<br>    )</pre><p>Every call to generate_credentials produces a unique username/password pair. The database user is automatically dropped when the lease expires — no cleanup needed.</p><h3>7. Token Renewal and Lease Management</h3><p>Vault tokens expire. Your long-running application needs to handle renewal gracefully.</p><pre>import hvac<br>import threading<br>import time<br>import os<br><br><br>class VaultClientWithRenewal:<br>    def __init__(self):<br>        self._client = hvac.Client(url=os.environ[&#39;VAULT_ADDR&#39;])<br>        self._authenticate()<br>        self._start_renewal_thread()<br>    def _authenticate(self):<br>        self._client.auth.approle.login(<br>            role_id=os.environ[&#39;VAULT_ROLE_ID&#39;],<br>            secret_id=os.environ[&#39;VAULT_SECRET_ID&#39;]<br>        )<br>    def _start_renewal_thread(self):<br>        def renew_loop():<br>            while True:<br>                try:<br>                    token_info = self._client.auth.token.lookup_self()<br>                    ttl = token_info[&#39;data&#39;][&#39;ttl&#39;]<br>                    # Renew when 75% of TTL has elapsed<br>                    sleep_time = max(ttl * 0.75, 60)<br>                    time.sleep(sleep_time)<br>                    self._client.auth.token.renew_self()<br>                    print(&quot;Vault token renewed successfully&quot;)<br>                except Exception as e:<br>                    print(f&quot;Token renewal failed: {e}. Re-authenticating...&quot;)<br>                    self._authenticate()<br>        thread = threading.Thread(target=renew_loop, daemon=True)<br>        thread.start()<br>    def get_secret(self, path: str) -&gt; dict:<br>        response = self._client.secrets.kv.v2.read_secret_version(path=path)<br>        return response[&#39;data&#39;][&#39;data&#39;]</pre><h3>8. Production Deployment Checklist</h3><p>Here’s what separates a proper Vault deployment from a dev setup:</p><p><strong>Infrastructure</strong></p><ul><li>[ ] Run Vault in HA (High Availability) mode with at least 3 nodes</li><li>[ ] Use a durable storage backend — Integrated Raft storage or Consul</li><li>[ ] Enable TLS — Vault should only be accessible over HTTPS</li><li>[ ] Put Vault behind a load balancer with health checks</li></ul><p><strong>Security</strong></p><ul><li>[ ] Disable the root token after initial setup</li><li>[ ] Use the principle of least privilege in all policies — grant only the paths an app actually needs</li><li>[ ] Enable audit logging (vault audit enable file file_path=/var/log/vault/audit.log)</li><li>[ ] Rotate the unseal keys and store them securely (HSM or cloud KMS auto-unseal is strongly recommended)</li><li>[ ] Use AppRole or platform-native auth — never token-based auth in production</li></ul><p><strong>Application</strong></p><ul><li>[ ] Never log secrets — ensure your logging framework masks credential values</li><li>[ ] Implement token renewal (see section 7)</li><li>[ ] Handle Vault unavailability gracefully — cache secrets locally with a short TTL as a fallback</li><li>[ ] Use dynamic secrets for databases wherever possible</li></ul><p><strong>A minimal production </strong><strong>docker-compose.yml for Vault with Raft storage:</strong></p><pre>services:<br>  vault:<br>    image: hashicorp/vault:latest<br>    cap_add:<br>      - IPC_LOCK<br>    ports:<br>      - &quot;8200:8200&quot;<br>    environment:<br>      VAULT_LOCAL_CONFIG: |<br>        {<br>          &quot;storage&quot;: {<br>            &quot;raft&quot;: {<br>              &quot;path&quot;: &quot;/vault/data&quot;,<br>              &quot;node_id&quot;: &quot;vault-1&quot;<br>            }<br>          },<br>          &quot;listener&quot;: [{<br>            &quot;tcp&quot;: {<br>              &quot;address&quot;: &quot;0.0.0.0:8200&quot;,<br>              &quot;tls_disable&quot;: true<br>            }<br>          }],<br>          &quot;api_addr&quot;: &quot;http://vault:8200&quot;,<br>          &quot;cluster_addr&quot;: &quot;http://vault:8201&quot;,<br>          &quot;ui&quot;: true<br>        }<br>    command: server<br>    volumes:<br>      - vault-data:/vault/data</pre><pre>volumes:<br>  vault-data:</pre><h3>Putting It All Together</h3><p>Here’s a minimal but complete Python application that follows all the best practices above:</p><pre># app.py<br>import os<br>import hvac<br>import sqlalchemy<br>from contextlib import contextmanager<br><br><br>class SecretsManager:<br>    &quot;&quot;&quot;<br>    Production-ready Vault secrets manager.<br>    Authenticates via AppRole, reads KV secrets,<br>    and generates dynamic database credentials.<br>    &quot;&quot;&quot;<br>    def __init__(self):<br>        self._client = hvac.Client(url=os.environ[&#39;VAULT_ADDR&#39;])<br>        self._login()<br>    def _login(self):<br>        self._client.auth.approle.login(<br>            role_id=os.environ[&#39;VAULT_ROLE_ID&#39;],<br>            secret_id=os.environ[&#39;VAULT_SECRET_ID&#39;]<br>        )<br>    def get_api_key(self, service: str) -&gt; str:<br>        secret = self._client.secrets.kv.v2.read_secret_version(<br>            path=f&#39;myapp/third-party/{service}&#39;,<br>            mount_point=&#39;secret&#39;<br>        )<br>        return secret[&#39;data&#39;][&#39;data&#39;][&#39;api_key&#39;]<br>    def get_database_engine(self) -&gt; sqlalchemy.Engine:<br>        lease = self._client.secrets.database.generate_credentials(<br>            name=&#39;myapp-role&#39;<br>        )<br>        creds = lease[&#39;data&#39;]<br>        ttl = lease[&#39;lease_duration&#39;]<br>        return sqlalchemy.create_engine(<br>            f&quot;postgresql://{creds[&#39;username&#39;]}:{creds[&#39;password&#39;]}&quot;<br>            f&quot;@{os.environ[&#39;DB_HOST&#39;]}/mydb&quot;,<br>            pool_pre_ping=True,<br>            pool_recycle=int(ttl * 0.8)<br>        )<br><br># Bootstrap once at application startup<br>secrets = SecretsManager()<br>engine = secrets.get_database_engine()<br>stripe_key = secrets.get_api_key(&#39;stripe&#39;)<br>print(&quot;✅ Application started with credentials from Vault&quot;)</pre><h3>Summary</h3><p>Approach Use Case Security Level KV v2 static secrets API keys, JWT secrets, config ✅ Good AppRole auth Long-running services ✅ Good AWS IAM auth Apps on AWS infrastructure ✅✅ Better Dynamic DB secrets Database credentials ✅✅✅ Best</p><p>The single most impactful change you can make is moving from static .env files to Vault KV secrets. The next most impactful is switching database credentials to dynamic secrets — suddenly a leaked credential has a TTL measured in minutes, not months.</p><p>Vault’s learning curve is real, but hvac makes the Python integration straightforward. Start with the KV engine and token auth locally, graduate to AppRole in staging, and add dynamic secrets in production.</p><p>Your future self — the one who doesn’t get paged at 3am because a credential leaked — will thank you.</p><p><em>All code examples are tested against Vault 1.15+ and hvac 2.x. For the full </em><em>hvac API reference, see </em><a href="https://hvac.readthedocs.io/"><em>hvac.readthedocs.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6e4039b4ce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Where Does EASM Fit in the Developer & Engineering Ecosystem?]]></title>
            <link>https://medium.com/@hessam.p/where-does-easm-fit-in-the-developer-engineering-ecosystem-cd12ce5acc42?source=rss-6d2e4930aa25------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd12ce5acc42</guid>
            <dc:creator><![CDATA[Hessam P]]></dc:creator>
            <pubDate>Fri, 30 Jan 2026 11:22:30 GMT</pubDate>
            <atom:updated>2026-01-30T11:22:30.200Z</atom:updated>
            <content:encoded><![CDATA[<p>As organizations scale their digital products, cybersecurity is no longer just a “security team problem” — it’s an engineering architecture problem.</p><p>Modern applications are built from microservices, APIs, cloud infrastructure, CI/CD pipelines, SaaS tools, third-party services, and distributed deployments. Every new repo, endpoint, bucket, domain, subdomain, webhook, and integration becomes a potential external exposure.</p><p>From a developer’s perspective, the real battlefield is not the internal network — it’s everything your code exposes to the internet.</p><p>This is where <strong>External Attack Surface Management (EASM)</strong> becomes relevant — not as a security product, but as an <strong>engineering visibility layer</strong> for modern systems.</p><p>The real question becomes:</p><blockquote><em>Where does EASM fit in the developer and engineering ecosystem?</em></blockquote><p>The answer:<br> EASM is not a separate security category — it is a <strong>cross-cutting visibility layer</strong> that connects engineering, DevOps, cloud infrastructure, and security.</p><h3>EASM as Part of Attack Surface Management (ASM) — for Engineers</h3><p>From a technical view, Attack Surface Management is simply <strong>asset discovery + exposure control</strong>.</p><p>It splits into:</p><ul><li><strong>Internal ASM (IASM)</strong> → internal services, internal networks, private APIs</li><li><strong>External ASM (EASM)</strong> → public endpoints, public APIs, public services, cloud assets</li></ul><p>For developers, this translates to:</p><ul><li>Which APIs are publicly reachable?</li><li>Which services are accidentally exposed?</li><li>Which environments are live on the internet?</li><li>Which test/staging systems are public?</li><li>Which ports, services, and endpoints exist outside intended design?</li></ul><p>So structurally:</p><p>System Architecture → Attack Surface Management → External Attack Surface Management (EASM)</p><p>EASM becomes part of <strong>system architecture visibility</strong>, not just security tooling.</p><h3>EASM in Engineering Risk Management</h3><p>From a dev perspective, risk is usually created by:</p><ul><li>Misconfigurations</li><li>Forgotten services</li><li>Legacy deployments</li><li>Temporary test systems</li><li>Debug endpoints</li><li>Unauthenticated APIs</li><li>Open ports</li><li>Exposed admin panels</li><li>Public cloud storage</li><li>Over-permissive IAM</li></ul><p>EASM helps answer technical questions like:</p><ul><li>What did we expose without realizing it?</li><li>Which deployments are still reachable?</li><li>Which services bypass auth?</li><li>Which endpoints violate security assumptions?</li><li>Which APIs are public but undocumented?</li></ul><p>So EASM becomes part of <strong>engineering risk visibility</strong>, not just cyber risk.</p><h3>EASM in DevOps, SRE, and Platform Engineering</h3><p>Operationally, EASM fits naturally into:</p><ul><li><strong>DevOps</strong></li><li><strong>Platform engineering</strong></li><li><strong>SRE</strong></li><li><strong>Infrastructure engineering</strong></li></ul><p>Use cases:</p><ul><li>Detecting shadow IT</li><li>Finding rogue services</li><li>Identifying orphaned deployments</li><li>Mapping real production exposure</li><li>Tracking infrastructure drift</li><li>Detecting misconfigured ingress/load balancers</li><li>Monitoring DNS, subdomains, and routing leaks</li></ul><p>This shifts teams from:</p><blockquote><em>“We think this is what’s exposed”<br> to<br> “This is what’s actually exposed.”</em></blockquote><p>Which is a massive difference in real-world systems.</p><h3>EASM as Developer-Focused Reconnaissance</h3><p>Attackers start with recon.<br> EASM does the same — but for defenders and engineers.</p><p>It shows:</p><ul><li>What domains/subdomains exist</li><li>What services respond</li><li>What APIs are visible</li><li>What tech stacks are exposed</li><li>What versions are running</li><li>What endpoints are public</li><li>What metadata leaks exist</li></ul><p>From a developer view:</p><blockquote><em>EASM shows your system as the internet sees it — not as your diagrams describe it.</em></blockquote><p>This makes it a <strong>reality-check layer</strong> for architecture diagrams and infrastructure design.</p><h3>EASM in Cloud, API, and Microservice Security</h3><p>Modern systems are API-first and cloud-native.<br> That makes EASM tightly connected to:</p><ul><li>Cloud infrastructure</li><li>Kubernetes</li><li>API gateways</li><li>Microservices</li><li>SaaS integrations</li><li>Event-driven systems</li><li>Serverless functions</li></ul><p>EASM helps detect:</p><ul><li>Public buckets</li><li>Exposed cloud services</li><li>Open dashboards</li><li>Unprotected APIs</li><li>Debug endpoints</li><li>Internal services leaking externally</li><li>Ingress misconfigurations</li><li>API gateway bypass paths</li></ul><p>So it becomes a <strong>bridge between code, infrastructure, and exposure</strong>.</p><h3>A Unified Engineering Model</h3><p>Instead of seeing EASM as “a security tool,” a better model is:</p><p><strong>EASM as an engineering visibility layer</strong></p><p>It connects:</p><ul><li>System architecture</li><li>Cloud infrastructure</li><li>APIs</li><li>DevOps pipelines</li><li>Platform engineering</li><li>Security operations</li><li>Risk management</li></ul><p>EASM becomes the <strong>external truth layer</strong> between your system and the internet.</p><h3>Final Developer Perspective</h3><p>From a developer and engineering standpoint:</p><p><strong>EASM is not only about hacking prevention — it’s about system visibility.</strong></p><p>It answers fundamental engineering questions:</p><ul><li>What did we expose?</li><li>What do attackers see?</li><li>What does the internet see?</li><li>What did automation create?</li><li>What did CI/CD deploy and forget?</li><li>What exists outside our design model?</li></ul><p>In modern architecture, complexity creates exposure by default.</p><p>So EASM becomes:</p><blockquote><em>A foundational external visibility layer that connects engineering, DevOps, cloud infrastructure, and security into one real-world exposure model.</em></blockquote><p>Or simply:</p><p><strong>If observability shows what happens inside your system,<br> EASM shows what your system looks like from the outside.</strong></p><p>That’s why EASM is becoming essential — not just for security teams, but for developers, architects, and platform engineers building internet-facing systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd12ce5acc42" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>