<?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 Pranav Kumaar on Medium]]></title>
        <description><![CDATA[Stories by Pranav Kumaar on Medium]]></description>
        <link>https://medium.com/@kumaarp.in?source=rss-ec1c8d359ab3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JvoAVdFqbHzZdgppQoVpcA.jpeg</url>
            <title>Stories by Pranav Kumaar on Medium</title>
            <link>https://medium.com/@kumaarp.in?source=rss-ec1c8d359ab3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 01:23:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kumaarp.in/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 does nobody check what’s Already Installed]]></title>
            <link>https://medium.com/@kumaarp.in/why-does-nobody-check-whats-already-installed-d06768be26dd?source=rss-ec1c8d359ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d06768be26dd</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Pranav Kumaar]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 13:18:57 GMT</pubDate>
            <atom:updated>2026-07-29T13:18:57.392Z</atom:updated>
            <content:encoded><![CDATA[<p>A build story about the gap between “I checked this package before installing it” and “I have twenty environments and no idea what’s in them.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GEc8Oxy7eNaDzIM1" /></figure><p>I spent a while reading incident reports about Python supply chain attacks, and I came out of it stuck on one specific thing.</p><p>Almost all the advice is about the moment of installation. Check the repo. Check the download count. Use a cooldown so you’re not installing something published an hour ago. Pin your dependencies. Lock with hashes. All of that is good advice and I gave most of it myself in the <a href="https://medium.com/@kumaarp.in/malicious-python-packages-dont-have-cves-that-s-the-whole-problem-df51a4483377">previous article</a>.</p><p>None of it helps with the environment you set up in March and haven’t opened since.</p><p>That’s the gap I kept circling. Package security is treated as a decision you make once, at install time, about one package, in one project. But an environment is a thing that persists. It sits on your disk for two years with fifty transitive dependencies you never consciously chose, and the world keeps learning new things about those packages after you stopped paying attention.</p><p>Nobody goes back and re-checks. There isn’t really a habit for it, and until recently I couldn’t find a tool shaped for it either.</p><h3>The question I couldn’t answer</h3><p>Here’s the concrete version. I have somewhere around fifteen virtual environments, some from projects I finished, some from experiments I abandoned, several created by a coding agent as a test base that I never looked at closely.</p><p>The question is: <strong>is there anything known-bad in any of them, right now?</strong></p><p>That should be easy. It isn’t, and the reason is that the available tools are shaped for a different question.</p><p>pip-audit is a good tool and I&#39;d recommend it. But it audits one project. You run it inside a repo, it looks at that environment or that requirements file, it calls out to a service, and it reports CVEs. To answer my question with pip-audit I&#39;d need to enumerate every environment on the machine myself, activate each one, run it, collect the output, and do that again next month. safety has broadly the same shape.</p><p>The other problem is the one I wrote about <a href="https://medium.com/@kumaarp.in/malicious-python-packages-dont-have-cves-that-s-the-whole-problem-df51a4483377">last time</a>: those tools are CVE-shaped, and a malicious package doesn’t get a CVE. If a package I installed last year was later identified as credential-stealing malware, that fact lives in a malicious-package feed, not in a vulnerability database. A CVE scanner will look straight past it.</p><p>So the question stayed unanswered, and eventually <a href="https://github.com/pranavkumaarofficial/venvy">I wrote something</a> to answer it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*j49tRSNTORQaw-9LzxjlWw.png" /></figure><h3>What it does</h3><p>The tool is called <a href="https://github.com/pranavkumaarofficial/venvy">venvy</a>. One command, venvy audit, and the design follows from the question rather than from what was easy to build.</p><p><strong>It works on the machine, not the project.</strong> It keeps a small local registry of the environments it knows about and audits all of them in one pass. On three environments it takes about 60 milliseconds after the database is built. The unit of work is your disk, not your current working directory.</p><p><strong>It checks for all malicious packages, not only vulnerable ones.</strong> The local database is compiled from OSV’s PyPI feed plus malicious-package datasets from DataDog and a typosquat list. That’s roughly 26,000 advisories, about 13,000 of which are malicious-package records rather than CVEs. Those two categories get reported separately, because “this version has a known flaw” and “this package is malware” call for very different reactions.</p><p><strong>The scan makes no network calls at all.</strong> It downloads a database once, then works offline forever. There’s an --offline flag that hard-fails if there&#39;s no local database, which matters for CI, where &quot;no findings because the network was down&quot; and &quot;no findings because you&#39;re clean&quot; must never look the same.</p><p><strong>It never imports anything from the environment it’s scanning.</strong> This one is a direct consequence of reading the LiteLLM report. That malware ran during installation, not on import. If your security scanner’s method of inspecting a package involves executing any part of it, your scanner is an attack surface. venvy reads dist-info metadata as text and nothing else.</p><p><strong>Output is built for automation.</strong> JSON with a versioned schema, and semantic exit codes with a defined precedence: malicious beats vulnerable beats stale-database beats clean. You can gate CI on it without parsing prose.</p><p>There’s a related reason I cared about the JSON. An LLM cannot be trusted to answer “is this package version vulnerable?” It will produce a confident, plausible, fabricated CVE number. But an agent can absolutely be trusted to run a command and read structured output. Being a deterministic lookup that an agent calls is a better role for this kind of tool than trying to be clever.</p><h3>How the data stays current</h3><p>The obvious question, and the one I got asked first: vulnerabilities are published constantly, so how does any of this stay useful a month from now?</p><p>The advisory database is not bundled into the package. It gets compiled on your machine from live upstream feeds, which means the data and the tool version are independent. A copy of venvy you installed in January will pick up today’s advisories the moment you run venvy audit --refresh. No upgrade, no release, no waiting on me. While writing this article I refreshed twice a few hours apart and the second run had picked up 95 advisories that didn&#39;t exist in the first.</p><p>What venvy deliberately does not do is update itself. A scan makes zero network calls, and I want to keep that true, because a security tool that quietly phones home in the middle of a run has broken both its determinism and your ability to run it somewhere locked down. So refreshing is something you schedule rather than something that happens to you. Every run prints how old the database is, and past two weeks it stops treating a clean result as trustworthy: you get a warning and the exit code changes, rather than a reassuring green from stale data.</p><p>Weekly is the cadence I’d suggest, and I’d push back on monthly. The LiteLLM compromise was quarantined 152 minutes after upload. A database that’s four weeks behind has missed entire attack cycles, including the part where the world figured out what happened. The cost of staying current is one download of about 25MB.</p><pre># Linux/macOS, weekly refresh via crontab -e<br>0 9 * * 1 venvy audit --refresh --json &gt; /tmp/venvy-audit.json</pre><p>There’s a failure mode in this design worth naming, because it’s the one that would quietly ruin everything: if an upstream feed changes a URL or a format, refresh breaks for every user at once and I’d find out from bug reports weeks later. So a scheduled job runs a real refresh against the live feeds every week, and fails loudly if a source errors or the compiled data comes back implausibly small. It also installs a deliberately vulnerable package into a throwaway environment and checks that venvy still flags it, because “the database compiled successfully” and “the tool still catches things” are not the same claim.</p><h3>The bugs that shaped it</h3><p>Two things I got wrong during development are more informative than the feature list.</p><p>The first was a false-negative machine. Real OSV records often carry two version ranges: an ecosystem range with real version numbers, and a git range whose boundaries are commit hashes. My matcher tried to parse the commit hashes as versions, failed, and fell back to reporting “unknown” rather than guessing. Safe, but it meant that common packages like cryptography and pip were coming back as unknown across the board. A tool that shrugs at everything is useless in a quieter way than a tool that lies. Fixed by evaluating only the ranges that describe package versions.</p><p>The second was worse, and I only found it because I went looking. A database file that was valid but empty, which could happen if a refresh downloaded something that parsed to zero records, would pass every check and then report a genuinely vulnerable environment as clean. Exit code zero. Green.</p><p>That’s the worst possible bug for this category of tool. A scanner that crashes tells you something is wrong. A scanner that says “you’re fine” when it has no data to base that on has actively made you less safe than running nothing, because now you think you checked.</p><p>So the rule became: anything the tool cannot confidently evaluate is reported as unknown, never as clean. A corrupt or empty database refuses to run at all rather than returning zero findings. There is no code path where absence of data produces a reassuring answer.</p><p>I mention this because “how does it behave when it’s broken” is a fair question to ask of any security tool, and most marketing pages don’t answer it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*Spj6NzNsjMltPosZ0I-Rdg.png" /></figure><h3>What it found on my own machine</h3><p>The first useful run flagged pytest 8.4.2 in one environment against a moderate-severity advisory with a fix available in 9.0.3, plus an assortment of findings against the old pip bundled into environments I&#39;d created a year ago.</p><p>That last category turned out to be worth a design decision. pip and setuptools ship inside nearly every environment and carry a lot of advisories, so on most machines they dominate the output and bury anything about your actual dependencies. venvy reports them but keeps them out of the exit-code gate by default. Otherwise every machine fails CI because of a bundled pip, everyone starts ignoring the tool, and the signal is worth nothing.</p><p>Nothing malicious, which is the expected and boring result. Known-malicious packages get yanked from PyPI quickly, so finding one on a working developer machine is rare. The value is in checking rather than in the drama of a hit.</p><h3>What it does not do</h3><p>This is the section I’d want to read first if someone showed me their security tool, so here it is plainly.</p><p><strong>It would not have caught LiteLLM.</strong> During the 152 minutes that attack was live, no database on earth contained a record of it. Nothing that works by matching against known advisories can catch a package that nobody has identified yet. That window belongs to cooldowns and lockfiles, not to scanners, and I said the same thing in the previous article before I had anything to sell you.</p><p><strong>It misses some famous typosquats.</strong> python3-dateutil, jeIlyfish and colourama, which are exactly the examples I used when writing about typosquatting, are not in the public feeds it compiles from and are not currently flagged. That bothers me. It&#39;s filed as an open issue with a proposed fix, which is ingesting the OpenSSF malicious-packages dataset, and anyone who wants to close it is welcome to.</p><p><strong>Coverage is only as good as public data.</strong> About 13,000 malicious records sounds like a lot until you consider that Sonatype logged 454,600 new malicious packages in 2025 alone. Most of those are npm, and most were never published to a feed I read. This tool tells you about known-bad packages. It does not tell you that you’re safe.</p><p><strong>Conda packages aren’t audited yet.</strong> It reads the pip-installed packages inside a conda environment, but not conda-channel packages, which have their own metadata format and their own version semantics. Also an open issue.</p><p><strong>I’d rather write all of that down than have someone discover it and conclude the rest was oversold.</strong></p><h3>Where it fits</h3><p>The honest framing is that this is one layer of four, and it’s the last one.</p><p>Cooldowns stop you being the early adopter of someone’s exploit. Lockfiles with hashes stop things changing underneath you. Least privilege means an install script doesn’t find your production credentials in the shell it runs in. And then, after all of that, something should periodically check what you already have against what the world has since figured out was bad.</p><p>That fourth layer was the one I couldn’t find a tool for, so I wrote one. It’s MIT licensed, it runs on Windows, macOS and Linux across Python 3.8 to 3.13, and if it ever reports a false positive or a false negative I want to hear about it, because those go straight into the test suite and stay there.</p><pre>pip install venvy<br>venvy audit</pre><p><a href="https://github.com/pranavkumaarofficial/venvy"><em>venvy on GitHub</em></a><em>. Disclosure: I’m the author, which is the entire point of this article, but it seemed worth saying explicitly.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d06768be26dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malicious Python Packages Don’t Have CVEs. That’s the Whole Problem.]]></title>
            <link>https://medium.com/@kumaarp.in/malicious-python-packages-dont-have-cves-that-s-the-whole-problem-df51a4483377?source=rss-ec1c8d359ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/df51a4483377</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Pranav Kumaar]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 15:47:44 GMT</pubDate>
            <atom:updated>2026-07-21T15:47:44.083Z</atom:updated>
            <content:encoded><![CDATA[<p>What the LiteLLM compromise, a year-long typosquat, and 454,600 malicious packages tell us about the gap in how we check dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ifvVGfCFeVNsAkUU" /></figure><p>On 2 April 2026, PyPI published <a href="https://blog.pypi.org/posts/2026-04-02-incident-report-litellm-telnyx-supply-chain-attack/">an incident report</a> about two packages: litellm and telnyx. Attackers had obtained API token access after exploiting a dependency in Trivy, then used it to publish malicious releases of both.</p><p>The malware ran on install. Not when you imported the library or when you called a function. LITERALLY when pip unpacked it. It harvested credentials and files from the machine and sent them to a remote endpoint.</p><p>Here is the timeline PyPI recorded for LiteLLM:</p><ul><li>Upload to first report: 1 hour 19 minutes</li><li>First report to quarantine: 1 hour 12 minutes</li><li>Total exposure: 2 hours 32 minutes</li></ul><p>In that window, the compromised versions were downloaded more than 119,000 times.</p><p>LiteLLM normally installs around 1,700 times per minute. Over 152 minutes that’s roughly 258,000 installs, which means somewhere close to half of everyone who installed LiteLLM during those two and a half hours got the malicious version. PyPI’s own estimate is that 40 to 50 percent of installs in that window involved unpinned versions. Telnyx was exposed for 3 hours 42 minutes.</p><p>Two and a half hours. Six figures of downloads. A package people had been using for months without incident.</p><p>Now here is the part that should bother you: at no point during those 152 minutes did a CVE exist for this. There was no advisory to match against, no identifier to look up, no database entry to check. If you had run a dependency scanner on your project at minute 90, it would have told you that you were fine.</p><p>It would have been wrong, and it would have been wrong for a structural reason rather than a fixable one.</p><h3>What a CVE actually is, and what it isn’t</h3><p>A CVE describes a flaw in code that someone wrote in good faith. Somebody made a mistake, a researcher found it, a maintainer confirmed it, an identifier was assigned, and it went into a database. The entire process assumes a defective-but-honest artifact and a disclosure timeline measured in days or weeks.</p><p>A malicious package is not a defect. It’s the code working exactly as its author intended. There is no maintainer to confirm the report, because the maintainer is the attacker, or the maintainer’s account was taken. There is no patch, because the fix is removal. And there is no disclosure window, because the whole strategy depends on the window being short.</p><p>This is why the tooling gap exists. Most application security tooling was built to find insecure code, not deliberately weaponized dependencies. Software composition analysis scanners read published vulnerability databases. Anything that was never in that model is invisible to them, and a package uploaded three hours ago has not been in any model.</p><p>There’s a line from <a href="https://www.endorlabs.com/learn/malicious-package-detection">Endor Labs’ write-up</a> on this that I keep coming back to:</p><blockquote>A package published 24 hours ago hasn’t been disclosed yet. By the time it appears in CVE feeds, it’s already been removed from registries and the damage is complete.</blockquote><p>Both halves of that sentence matter. The advisory arrives after the attack, and it arrives describing something that is no longer downloadable. It’s an obituary, not an alarm.</p><p>The same dynamic explains why SolarWinds never produced a CVE for the malicious build. Nothing was vulnerable. Something was hostile. Those are different words and we mostly have tools for the first one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*e6Csw8vJDAwm24apzxLgIw.png" /></figure><h3>Two shapes of attack, both invisible to the same tool</h3><p>LiteLLM is the fast shape. Compromise a trusted package, ship a malicious version, collect whatever arrives in the next two hours, get quarantined. The attack is designed to be over before the disclosure machinery can start.</p><p>The slow shape looks completely different and defeats the same scanner.</p><p>In December 2019, a developer named Lukas Martini noticed two packages on PyPI: python3-dateutil and jeIlyfish. The second one is the interesting one. Look closely: it is jeIlyfish with a capital I, imitating the lowercase L in jellyfish. In most sans-serif fonts, including the one PyPI used, those two characters are visually identical.</p><p>The package <a href="https://www.sysdig.com/blog/malicious-python-libraries-jeilyfish-dateutil">stole SSH and GPG keys</a>.</p><p>It had been on PyPI since 11 December 2018. Nearly a year. python3-dateutil, squatting the very widely used python-dateutil, was only live for two days and was downloaded 381 times. The year-old one had around 119 downloads.</p><p>A hundred and nineteen downloads sounds like nothing until you consider what it took. SSH private keys and GPG signing keys, from a hundred-odd developer machines, belonging to people who trusted a library name they misread. Some of those keys unlock production infrastructure. Some of them sign releases that other people install.</p><p>Both packages were removed the day they were reported. Which brings up the detail I find hardest to get past: they were found by a person. Not a scanner, not an automated pipeline, not the registry. A developer looked at a package name and thought it looked wrong.</p><p>One attack was too fast for the disclosure process. The other sat still for a year and nothing noticed. Neither had a CVE while it mattered.</p><h3>The scale, with an honest caveat</h3><p>Sonatype’s <a href="https://www.sonatype.com/state-of-the-software-supply-chain/2026/open-source-malware">2026 supply chain report</a> puts numbers on this. During 2025 they identified 454,600 new malicious packages. The cumulative total of known and blocked malware passed 1.233 million. By Q2 2026 that figure had reached about 1.8 million logged over the preceding decade.</p><p>The trend line is the part worth reading twice: 2026, barely half over, had already produced 2.6 times the campaign volume and 4.5 times the package volume of the entire year before it.</p><p>Now the caveat, because I think overstating this does more harm than good. The overwhelming majority of those packages are on npm, roughly 96.6 percent by Sonatype’s Q2 count. PyPI is a much lower-volume target. Sonatype describes the PyPI activity as lower volume but higher signal, which matches what the incidents look like: fewer packages, aimed more carefully.</p><p>So no, PyPI is not drowning in half a million malicious packages. The number that matters for a Python developer isn’t the total, it’s that the attacks which do land are aimed at packages you have already installed and already trust.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xQPPQNcXIFsmPyic" /></figure><h3>Why the usual advice failed here</h3><p>Ask developers how they decide a package is safe and you get a fairly consistent list. Check the GitHub repo. Look at recent commits. Check the download count. See if the maintainer has other projects. Look for anything weird in setup.py.</p><p>That list is genuinely good, and I use it. Against LiteLLM it would have done nothing.</p><p>LiteLLM was an established package with real maintainers, an active repository, a large download count, and a history of legitimate releases. Every heuristic on that list returns green. The compromise didn’t come through the package’s reputation; it came through a stolen API token, upstream of everything a developer can inspect.</p><p>Typosquats are the case where the heuristics work, because a package with 119 downloads and no history is exactly what the checklist is designed to catch. Account compromise of a popular package is the case where they don’t, and that’s the direction attacks have moved.</p><p>There’s a second, quieter failure. Those heuristics all run at install time. You evaluate a package once, decide it’s fine, and then never look at it again. Meanwhile the environment you installed it into sits on your disk for two years accumulating transitive dependencies you never consciously chose. Nobody re-audits an environment they stopped working in.</p><h3>What actually helps</h3><p>I want to be careful not to end this with a neat solution, because there isn’t one. But there are things that measurably shrink the window, and PyPI recommends most of them in that same incident report.</p><p><strong>Cooldowns are the single highest-value change.</strong> Don’t install anything published in the last few days. In uv that’s --exclude-newer &quot;P3D&quot;; pip added --uploaded-prior-to P3D in 26.1. LiteLLM was quarantined in 152 minutes. Telnyx in under four hours. A three-day cooldown would have made both attacks miss you entirely, and it costs you almost nothing, because you rarely need a release that shipped this morning.</p><p>This is the closest thing to a free win in this entire article. It works precisely because attackers depend on speed.</p><p><strong>Lock with checksums, not </strong><strong>pip freeze.</strong> A lockfile with hashes means an unexpected artifact fails the install instead of running it. uv lock or pip-compile produce this. pip freeze records versions, not hashes, and versions are what the attacker controls.</p><p><strong>Assume install-time code execution.</strong> The LiteLLM malware ran during installation. Not on import. That means “I’ll install it and look at it before I use it” is not a safety strategy. If you are evaluating something you don’t trust, do it in a container or a VM, not in the shell where your cloud credentials and SSH agent live.</p><p><strong>Scan for known-bad across everything you’ve already installed.</strong> This is the part people skip. Tools like pip-audit and safety are useful and I&#39;d recommend running them, but be clear about their shape: they&#39;re per-project, they&#39;re CVE-focused, and they mostly need network access. They will tell you about a vulnerable version of requests in the repo you&#39;re currently in. They will not tell you that an environment you abandoned in March contains a package that was later identified as malicious.</p><p>That last gap is worth sitting with. Detection of malicious packages happens after the fact almost by definition. Something gets published, someone catches it, it gets recorded in a malicious-package feed. That record is useless to you unless something goes back and checks what you already have.</p><p><strong>For maintainers:</strong> trusted publishers instead of long-lived API tokens, and 2FA everywhere. The LiteLLM compromise was a token compromise. Tokens are the soft part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*49M06Ll_2XJBCkbhgRf2zA.png" /></figure><h3>The thing nobody can sell you</h3><p>No scanner would have caught LiteLLM at minute 30. Not mine, not a commercial one, not one that doesn’t exist yet. During the window where it mattered, there was nothing to match against, because the only fact available was “this version is new” and new is not the same as malicious.</p><p>Behavioral analysis tools try to close that gap by looking at what a package does rather than what a database says about it. Socket detected more than 1,700 malicious packages tied to a single North Korean campaign in the first half of 2025, most of which had no CVE. That approach genuinely catches things database lookups can’t, and it comes with the false-positive cost that behavioral detection always carries.</p><p>The realistic posture is layered and slightly boring. Cooldowns so you’re not the early adopter of someone’s exploit. Lockfiles with hashes so nothing changes underneath you. Least privilege, so an install script doesn’t find your production keys sitting in the environment. And periodic scanning of what you already have, for the things the world has since figured out were bad.</p><p>That last layer is the one I found genuinely missing when I went looking, and it’s the one I ended up building something for. But the honest framing is that it’s a layer, not an answer. The 152 minutes belong to the attacker. What you get to control is everything after.</p><p><em>I maintain </em><a href="https://github.com/pranavkumaarofficial/venvy"><em>venvy</em></a><em>, an MIT-licensed tool that scans every Python environment on a machine for both vulnerable and known-malicious packages, offline. Disclosure: I’m the author. It does not solve the 152 minutes, and I say so in the README.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df51a4483377" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your Python Virtual Environments Are Eating Your Disk]]></title>
            <link>https://medium.com/@kumaarp.in/why-your-python-virtual-environments-are-eating-your-disk-3bbaae838994?source=rss-ec1c8d359ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bbaae838994</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Pranav Kumaar]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 15:46:42 GMT</pubDate>
            <atom:updated>2026-07-21T15:46:42.606Z</atom:updated>
            <content:encoded><![CDATA[<p>A look at why every environment stores its own copy of everything, what uv and conda actually fixed, and what to do about the pile you already have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ha75iMEecGgCKk_Q" /></figure><p>Run this if you’re on Linux or macOS:</p><pre>du -sh ~/.virtualenvs/* 2&gt;/dev/null | sort -h | tail</pre><p>On Windows, point it at wherever your .venv folders live. The number at the bottom is usually worse than people expect.</p><p>In February 2020, a developer ran that command and opened <a href="https://github.com/pypa/packaging-problems/issues/328">an issue</a> on the Python Packaging Authority’s packaging-problems tracker. Their environments directory was over 6GB. Most individual environments were over 400MB. The observation in the issue is simple and, six years later, still true:</p><blockquote>there are a lot of packages which are common across all the environments and there are few packages which are different</blockquote><p>They asked for what pnpm does in the Node world: one global store, and links from each project into it. The issue is titled “Disk space efficient package manager for Python.”</p><p>Crazy part is it’s still open. No assignee or pull request. Its been six years.</p><p>I want to walk through why this happens, what parts of the ecosystem have actually fixed it, and what you can do about the environments already sitting on your disk, because those turn out to be different problems with different answers.</p><h3>Why environments duplicate everything</h3><p>The duplication isn’t a bug. It’s the entire point.</p><p>A virtual environment exists so that project A can use requests 2.19 while project B uses 2.32 and neither knows the other exists. The simplest way to guarantee that isolation is to give each environment its own complete copy of everything. pip extracts the wheel into site-packages and moves on. No shared state, no coordination, nothing to go wrong.</p><p>That’s a reasonable engineering trade, and for years the cost was acceptable because Python packages were small. A pure-Python library is a few hundred kilobytes. Ten copies of it is a rounding error.</p><p>Then machine learning happened.</p><p>A developer on the PyTorch forums reported that <a href="https://discuss.pytorch.org/t/pytorch-install-is-that-large-5-gbs/213629">installing PyTorch took their environment from 600MB to 5.7GB</a>. That’s one install. A TensorFlow install runs around 2GB on its own. If you have five projects using TensorFlow, that’s roughly 10GB on disk to store the same bytes five times.</p><p>The isolation model didn’t change. The size of the things being isolated changed by three orders of magnitude.</p><h3>What the ecosystem actually fixed</h3><p>Two tools solved this properly, and it’s worth being precise about what each one covers, because the difference matters.</p><p><strong>conda</strong> hardlinks packages out of its package cache into each environment. When you create a conda environment and install numpy, conda doesn&#39;t copy numpy in; it points the new environment&#39;s files at the copy already in pkgs. Two environments with the same numpy build share the same bytes on disk. This has worked for years and it&#39;s one of the genuinely good things about conda that people rarely mention.</p><p>The catch: it covers conda-channel packages. Anything you pip install inside a conda environment is a normal pip install and gets its own copy.</p><p><strong>uv</strong> does the same thing for the pip world, and does it well. uv keeps a global cache and, on filesystems that support it, <a href="https://xebia.com/blog/uv-the-engineering-secrets-behind-pythons-speed-king/">hardlinks or copy-on-write clones package files</a> into each environment it creates. A wheel is downloaded and unpacked once and then reused by every environment on the machine that needs that exact version and platform tag. This is the pnpm model that the 2020 issue asked for, and it arrived about four years later from outside the packaging authority entirely.</p><p>If you use uv for everything and you started using it from scratch, this problem is mostly solved for you and you can stop reading.</p><p>Most people are not in that position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*49M06Ll_2XJBCkbhgRf2zA.png" /></figure><h3>The gap: your existing pile</h3><p>Here’s the thing that took me a while to notice. uv fixes duplication <strong>for environments uv creates</strong>. It has no opinion about the twenty environments already sitting in your projects folder, created over three years by python -m venv and pip install.</p><p>Those are just directories full of files. Nothing is going to retroactively deduplicate them. Switching to uv tomorrow doesn’t shrink them by a single byte.</p><p>And that pile is bigger than people think, for a reason that surprised me when I measured it: duplication happens <em>inside</em> a single environment too. pip vendors its own copy of pyparsing. So does setuptools. Scan three environments and you&#39;ll find the same pyparsing.py six times, because each environment contains two copies before you&#39;ve installed anything at all.</p><p>The conventional advice for the existing pile falls into two categories, and neither is great.</p><p><strong>Delete things.</strong> Tools like killpy and venv-clean find environments you haven&#39;t touched in months and remove them. This works, and I&#39;d genuinely recommend it as a first pass. But deleting is not reclaiming. You lose the environment. If you come back to that project in April you&#39;re rebuilding from a requirements.txt that may no longer resolve the same way.</p><p><strong>Share packages across environments.</strong> The usual suggestions are --system-site-packages, or manually symlinking common libraries. The first breaks the isolation you created the environment for in the first place. The second works acceptably for small pure-Python packages and starts causing genuinely confusing bugs the moment you try it with compiled extensions.</p><p>There’s a third option that I think is underused, and it’s the same trick conda and uv are already using, just applied after the fact.</p><h3>Hardlinks, applied to the pile you already have</h3><p>A hardlink is two directory entries pointing at the same data on disk. Not a shortcut, not a symlink that can dangle. Both paths are equally real, both are the file, and the filesystem only stores the bytes once. Delete one, the other keeps working.</p><p>If two environments contain a byte-for-byte identical copy of the same file, you can replace one with a hardlink to the other and reclaim its space. Both environments keep working. Nothing is deleted. Nothing changes about how imports resolve.</p><p>I measured this on three of my own environments. Small ones, mostly pure-Python dependencies, nothing like a torch install. The result was 18.2MB reclaimable across 659 groups of duplicate files, out of about 73MB total. Roughly a quarter of their combined size, from three environments that barely had anything in them.</p><p>Scale that mentally to environments that each contain a copy of torch and the number stops being interesting and starts being the reason your SSD is full. I want to be careful here: I have not measured a multi-torch machine, so I’m not going to quote you a figure for one. The mechanism is the same, the arithmetic is obvious, and I’d rather you run it yourself than trust a number I made up.</p><h3>The part that will bite you if you try this</h3><p>If you’re going to deduplicate files by hardlinking them, there is one failure mode that matters more than all the others, and it’s worth understanding before you run anything (including anything I wrote).</p><p>Hardlinked files share the same inode. If a process opens one of them and writes to it <strong>in place</strong>, every other path pointing at that inode sees the change. You wanted to save disk; you accidentally built a channel between environments that were supposed to be isolated.</p><p>For package payload files, this is fine in practice. pip and uv don&#39;t edit installed files in place. When you upgrade a package they delete the old files and write new ones, which creates a new inode and quietly breaks the link. The sharing ends exactly when it should.</p><p>Bytecode is a different story. CPython writes .pyc files, and it rewrites them when it decides they&#39;re stale. That write can happen in place. Deduplicating __pycache__ across environments is how you&#39;d corrupt several environments at once and spend an afternoon confused about it.</p><p>So: never deduplicate .pyc. Verify file identity with a hash rather than trusting size and timestamp. Hardlinks can&#39;t cross filesystems, so check that both files are on the same device. And if you&#39;re replacing a file with a link, create the link under a temporary name and rename it over the target, so a crash halfway through leaves you with a real file instead of a hole.</p><p>None of this is exotic. It’s the same set of precautions conda and uv already take. But “just hardlink the duplicates” is the kind of advice that sounds trivial and isn’t.</p><h3>What about AI agents</h3><p>An observation rather than a statistic, because I couldn’t find real data and I’m not going to invent it.</p><p>Coding agents create environments at a rate humans don’t. Every throwaway experiment gets its own project directory, and every project directory gets its own environment, and each one installs the same handful of libraries again. Nobody’s watching the disk while it happens, and nobody goes back to clean up a folder the agent made three weeks ago.</p><p>If the pre-agent version of this problem was a developer accumulating twenty environments over three years, the current version is accumulating twenty over a month. I don’t have numbers. I do have a laptop that fills up faster than it used to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*e6Csw8vJDAwm24apzxLgIw.png" /></figure><h3>What I’d actually do</h3><p>In order, cheapest first:</p><p>Clear your package cache. pip cache purge or uv cache prune. This is pure waste with no downside and most people have never run it.</p><p>Delete environments you genuinely won’t return to, and be honest about which those are. Anything from a project you abandoned is fine to lose.</p><p>Use uv for new work. It solves this going forward, and it’s faster at everything else too.</p><p>Then, for what’s left, deduplicate identical files with hardlinks rather than deleting environments you still want.</p><p>The thing worth taking away is that this is not a solved problem that you’ve failed to keep up with. It’s an open ticket on the packaging authority’s own tracker, filed in 2020, still unassigned. The tooling that fixed it fixed it forward, not backward. The pile you already have is still yours to deal with.</p><p><em>I wrote a small MIT-licensed tool called </em><a href="https://github.com/pranavkumaarofficial/venvy"><em>venvy</em></a><em> that does the hardlink deduplication described above across every environment it knows about, with the safety rules from that section built in. It’s read-only until you tell it otherwise. Disclosure: I’m the author, so weigh accordingly.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bbaae838994" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 2026 World Cup is being stolen by its goalkeepers]]></title>
            <link>https://medium.com/@kumaarp.in/the-2026-world-cup-is-being-stolen-by-its-goalkeepers-a5bf0605b1fe?source=rss-ec1c8d359ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5bf0605b1fe</guid>
            <category><![CDATA[data-journalism]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[soccer]]></category>
            <category><![CDATA[world-cup]]></category>
            <category><![CDATA[football]]></category>
            <dc:creator><![CDATA[Pranav Kumaar]]></dc:creator>
            <pubDate>Tue, 07 Jul 2026 14:31:01 GMT</pubDate>
            <atom:updated>2026-07-07T14:31:01.141Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A 40-year-old journeyman nicknamed “Granny” held Spain scoreless and pushed Messi to the brink. He turned out to be the face of the tournament’s strangest trend.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*xcGsgbYoGwfRCF3U" /><figcaption>Vozinha</figcaption></figure><p>On June 15, in a stadium in Atlanta, a 40-year-old who plays club football in Portugal’s second division stood in front of the reigning European champions and would not let them score.</p><p>Spain took 27 shots. Seven were on target. Cape Verde’s Vozinha saved all seven. When the whistle went on a 0–0 draw, he crouched by his goal and cried. It was his country’s first World Cup match ever, and its first World Cup point, and he had more or less earned it by himself. He had not even turned professional until he was 25.</p><p>That picture travelled around the world in a night. But the longer you watch this tournament, the more it looks like Vozinha was not a one-off. He was the loudest example of something bigger. This is a goalkeepers’ World Cup, and the numbers back it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*djjUslh_2xJuybSH.JPG" /></figure><h3>The Vozinha tournament, by the numbers</h3><p>His run reads like a script someone would send back for being too far-fetched.</p><p>Cape Verde came in ranked 67th in the world. Spain came in ranked 2nd. FIFA later called the draw one of the biggest ranking upsets the tournament has ever produced. Vozinha’s night: seven saves, a clean sheet, an 8.8 match rating from Flashscore, and Player of the Match. Six of the seven saves came from inside his own box.</p><p>Then he kept going. Another clean sheet against Saudi Arabia. And in the Round of 32 against Argentina, he arguably played even better in defeat: eight saves in a 3–2 extra-time loss, one of them a stop on a Messi free kick that had no right to stay out.</p><p>Over the whole tournament he faced 23 shots and saved 18. That is a .782 save rate, level with the best in the field, and it left him third for total saves at the point Cape Verde went out. His team never lost inside 90 minutes. The only defeat came in extra time, against the team with Messi in it.</p><p>The records he collected belong to another era of the game. At 40 years and 12 days he became the oldest player ever to appear in his country’s first World Cup match. He became the third-oldest goalkeeper to keep a clean sheet at a World Cup, behind only Peter Shilton and Dino Zoff. And he became just the fifth player aged 40 or over to feature in a World Cup knockout tie.</p><p>His Instagram told the human version. Around 48,000 followers before the Spain game. Over a million within half an hour of full time. Into the millions in the weeks after.</p><blockquote>If you love math and would want to see some heuristics and code, check my other article over <a href="https://medium.com/@kumaarp.in/the-siege-curve-a-data-science-model-for-the-2026-world-cups-goalkeeper-boom-d13859f237e8">here</a></blockquote><h3>He was not alone</h3><p>Here is what turns one great story into a pattern. Look away from Cape Verde and the same thing keeps happening.</p><p>Curaçao’s Eloy Room, 37 years old, made sixteen saves in one match against Ecuador. That equalled Tim Howard’s famous 2014 record for the most saves in a 90-minute World Cup game, and it earned Curaçao its first World Cup point. Room actually held the “oldest man in a nation’s debut match” record himself for a day, until Vozinha took it off him.</p><p>Paraguay’s Orlando Gill knocked Germany out. He held his nerve through a penalty shootout to send one of the favourites home, and FIFA’s Power Rankings put him top of their “defending the goal” category after the Round of 32.</p><p>Saudi Arabia’s Mohammad Al-Owais made nine saves against Uruguay, in a Group H that commentators kept describing by its goalkeeping rather than its attacking.</p><p>England’s Jordan Pickford made three big saves in a 3–2 win over Mexico that England probably should have lost, and jumped up the Golden Glove betting because of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*khQ-Zz1_xBIQXTaD.jpg" /><figcaption>Pickford</figcaption></figure><p>And the household names have not even hit their stride. On July 6 the Golden Glove market had France’s Mike Maignan as favourite, ahead of Argentina’s Emiliano Martínez, Spain’s Unai Simón, and Pickford, with Ronwen Williams, Diogo Costa, Yassine Bounou, and Thibaut Courtois all still in the draw.</p><p>For scale: Croatia’s Dominik Livakovic set the modern marker with 25 saves across the entire 2022 tournament on the way to a semi-final. In 2026, single games are starting to make that number look small.</p><h3>Why this tournament, and why now</h3><p>None of it is luck, and the reasons are worth knowing.</p><p>The format did half the job. This is the first 48-team World Cup. More teams means more games, more knockout rounds, and a lot more matches where a heavy underdog spends 90 minutes pinned inside its own half. That is exactly where 16-save afternoons come from. Put Cape Verde, Curaçao, and Saudi Arabia in the same tournament as Spain, Argentina, and Germany, and you are almost designing the highlight reel in advance.</p><p>The job itself has changed too. A keeper today is a different athlete from one twenty years ago. Video analysis is now detailed enough that keepers walk into shootouts with notes taped to their water bottles, listing where each taker likes to shoot. Shot-stopping gets drilled with real sports science behind it. And ever since Manuel Neuer, still Germany’s number one at nearly 40, made the sweeper-keeper normal, the whole job has grown. Keepers are coached better, prepared better, and scouted better than they have ever been.</p><p>The underdogs leaned all the way in, as well. Most of the best displays came not from the famous names but from the men expected to defend for their lives. If your team cannot win a game on possession, a great goalkeeper is the one thing that drags a mismatch back toward level. It is the single position where one player can do that on his own.</p><p>Add it up and you get a tournament where, on June 15 alone, four games across two groups finished level, eight teams took a point each, and the day belonged almost entirely to the men in gloves.</p><h3>The save that outlived the match</h3><p>There is an old line that goalkeepers win World Cups with a save in a quarter-final instead of a goal in the final, that they are the tournament’s quiet heroes. In 2026 they have not been quiet. They have been the main event.</p><p>Vozinha goes home without a trophy. Cape Verde are out. But he leaves as one of the most loved figures of the whole thing, a 40-year-old who spent nineteen years grinding through Moldova, Angola, Cyprus, and Slovakia for one month where the football world finally learned his name. The grandparents who raised him, and who gave him the nickname “Granny,” did not live to see it. “I worked all my life for this,” he said afterward. You believe him.</p><h3>A small, “not so useful” footnote</h3><p>I liked this story enough to do something silly with it.</p><p>I build things in the terminal, and a goalkeeper’s whole job, turning people away at the line, is basically what a good security guard does to a dangerous command. So I made a little open-source tool called keeper. It renders Vozinha (or any image) as ASCII art in your terminal and throws up an ACCESS DENIED screen. It plugs into Claude Code as a safety hook. When the AI tries to run something reckless, like rm -rf, a force-push to main, or a fork bomb, Vozinha dives in and blocks it. Command denied. Safe commands walk straight through.</p><p>It is entirely a tribute and only slightly useful, which feels about right for the man it is named after. Check my other article over <a href="https://medium.com/@kumaarp.in/the-siege-curve-a-data-science-model-for-the-2026-world-cups-goalkeeper-boom-d13859f237e8">here</a></p><pre>pip install vozinha-keeper<br>keeper</pre><p>Code is here: <a href="https://github.com/pranavkumaarofficial/keeper">github.com/pranavkumaarofficial/keeper</a></p><p><strong>Obrigado, Vozinha.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5bf0605b1fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Siege Curve: a data-science model for the 2026 World Cup’s goalkeeper boom]]></title>
            <link>https://medium.com/@kumaarp.in/the-siege-curve-a-data-science-model-for-the-2026-world-cups-goalkeeper-boom-d13859f237e8?source=rss-ec1c8d359ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d13859f237e8</guid>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[soccer-analytics]]></category>
            <category><![CDATA[world-cup]]></category>
            <dc:creator><![CDATA[Pranav Kumaar]]></dc:creator>
            <pubDate>Tue, 07 Jul 2026 14:21:00 GMT</pubDate>
            <atom:updated>2026-07-07T14:21:00.773Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The field grew 50%. Goalkeeper masterclasses roughly tripled. I built a small Monte Carlo model to figure out why, and the answer is not the one most people give.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*ch5X7MYw3sjPyEmE" /></figure><p>Every World Cup has a theme it backs into by accident. I boldly say 2026’s theme is goalkeepers. A 40-year-old from Cape Verde held Spain scoreless. A 37-year-old from Curaçao made sixteen saves in one game and tied a record that had stood since 2014. Saudi Arabia’s keeper made nine against Uruguay. Paraguay’s knocked Germany out on penalties.</p><p>The usual explanation is “keepers are just better now”: more video analysis, more sports science, the sweeper-keeper revolution. All true, and all boring, because none of it explains why the spike landed in <em>this specific tournament</em> rather than being spread evenly across the last decade.</p><blockquote>If you hate math (just like me!) and want to just read, I have another article I wrote over <a href="https://medium.com/@kumaarp.in/the-2026-world-cup-is-being-stolen-by-its-goalkeepers-a5bf0605b1fe">here</a></blockquote><p>So I did the thing you do when a narrative feels too tidy. I built a model, calibrated it to the real numbers, and let it argue back. The short version: the biggest single cause is not the keepers at all. It is the format.</p><h3>Start with the facts that are not in dispute</h3><p>2026 is the first 48-team World Cup, up from 32. That is not a 50% bigger tournament in matches. It is far more.</p><p>The old 32-team format ran 64 matches. The new 48-team format runs 104. That is 40 extra games, including a brand-new Round of 32, a full extra round of single-elimination knockouts. The group stage alone went from 48 matches to 72.</p><p>Now the anchor performances, all sourced from FIFA, Opta, ESPN, and FOX Sports Research:</p><ul><li>Vozinha (Cape Verde, ranked 67th) faced Spain (ranked 2nd) and saved all 7 of their shots on target. Across the tournament he saved 18 of 23 shots on target, a .782 save rate.</li><li>Eloy Room (Curaçao) made 16 saves against Ecuador, equalling Tim Howard’s 2014 record for the most saves in a 90-minute World Cup match.</li><li>Mohammad Al-Owais (Saudi Arabia) made 9 against Uruguay.</li><li>For scale: Dominik Livakovic’s celebrated 2022 run produced 25 saves across seven matches. In 2026, single games are flirting with two-thirds of that.</li></ul><h3>The hypothesis: saves are a symptom of mismatch</h3><p>Here is the causal chain I wanted to test:</p><pre>bigger field  -&gt;  more mismatched games  -&gt;  more &quot;siege&quot; games<br>(one keeper peppered)  -&gt;  more huge single-match save counts</pre><p>A goalkeeper does not choose to make 16 saves. He makes 16 saves because his team was pinned in its own box for 90 minutes, which happens when the two teams are badly mismatched. Saves are downstream of shots faced, and shots faced are downstream of how outgunned you are. If that chain is real, then a format that manufactures more mismatches will manufacture more goalkeeper heroics, mechanically, without anyone getting better at goalkeeping.</p><h3>Step one: the Siege Curve</h3><p>First I needed a function mapping mismatch to saves. I used the favourite’s win probability w (from an Elo difference) as the measure of mismatch, and modelled the shots on target the underdog keeper faces as growing exponentially with it:</p><pre>expected_shots_on_target(w) = 3.3 * exp(2.16 * (w - 0.5))<br>expected_saves(w)           = 0.70 * expected_shots_on_target(w)</pre><p>The constants are calibrated, not invented. An even game (w = 0.5) puts a keeper at roughly 3.3 shots on target, the World Cup baseline. The steepness is set so a heavy favourite (w near 0.88, the rough Cape Verde-versus-Spain gap) drives the underdog keeper to about 7.5 shots on target. The 0.70 is a save rate; elite keepers this tournament are running higher, Vozinha at .782.</p><p>favourite win probexp. shots facedexp. saves0.50 (even)3.32.30.705.13.60.88 (Spain-ish)7.55.20.95 (total mismatch)8.76.1</p><p>A useful sanity check falls out of this. At the Spain mismatch the curve expects about 5.2 saves. Vozinha made 7. That gap is the point: a real siege game is a high expected value <em>plus</em> a good night on top. The model is not trying to reproduce him exactly; it is trying to get the average right so the tail behaves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*st8inDH8-FNU-4yn" /><figcaption><em>The exponential curve, the 8-save “siege line,” and where Vozinha vs Spain lands</em></figcaption></figure><h3>Step two: simulate two World Cups</h3><p>With the curve in hand, I ran a Monte Carlo. Assign every nation an Elo rating. Draw the field into groups of four. Play every group match. In each one, take the favourite’s win probability, draw the underdog keeper’s shots on target from a Poisson distribution around the Siege Curve, and turn each shot into a save with probability 0.70. Count the “siege games,” matches where one keeper makes 8 or more saves. Then do it 20,000 times, for a 32-team field and a 48-team field.</p><p>The one modelling choice that matters: the 48-team field is the 32-team field <em>plus a weaker tail</em>. Expansion does not add more teams like Spain. It adds teams ranked 40th to 70th and beyond, the Cape Verdes and Curaçaos. That is the whole mechanism, so I encoded it directly: the extra 16 teams extend the rating distribution downward.</p><p>Here is what 20,000 simulated tournaments each returned.</p><p>32-team48-teamgroup matches4872avg siege games (8+ saves)1.675.06siege games per 100 matches3.487.02chance of a 16+ save game~0.03%~0.4%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FeujvJ_dbdi2hBLX" /><figcaption><em>The distribution of siege games per tournament, 32-team vs 48-team</em></figcaption></figure><h3>The finding: it is not just more games</h3><p>This is the part I had not seen argued anywhere, and it is the reason I bothered writing code instead of a hot take.</p><p>Siege games went from 1.67 to 5.06 per tournament. That is a 3.03x increase. But the field only grew by 1.5x. So where did the rest come from? Decompose it:</p><pre>total siege increase   = 3.03x<br>  volume effect        = 1.50x   (simply more matches)<br>  mismatch effect      = 2.02x   (a higher siege rate per match)<br>  ------------------------------<br>  1.50 x 2.02          = 3.03</pre><p>Exactly half of the multiplier is volume. The other half is that <em>each individual group game is now more than twice as likely to become a siege</em>, because the average game is more lopsided than it used to be. A 32-team World Cup runs 3.48 sieges per 100 matches. A 48-team one runs 7.02. Same sport, same keepers, double the rate, purely because of who is now in the field.</p><p>The record-tying number is even starker in relative terms. A single 16-save game, the Howard and Room performance, is roughly an order of magnitude more likely in the 48-team field (about 0.4% per tournament versus 0.03%). Still rare. But 2026 already produced one, which is exactly what “rare event, now much more likely” looks like in practice.</p><h3>A prediction you can check</h3><p>A model is only worth anything if it sticks its neck out. This one predicts that a full box-score audit of all 72 group-stage games in 2026 should turn up on the order of 5 siege games (8+ saves), against fewer than 2 in a 32-team edition. I only have the marquee ones (Room’s 16, Al-Owais’s 9), and they land squarely in range. If someone pulls every group-stage keeper line and the count comes in near 5, the format story holds. If it comes in at 2, my curve is too steep and I am wrong. That is the deal.</p><h3>What this is not</h3><p><strong>This is a toy model, and calling it anything grander would be dishonest.</strong> The Siege Curve is calibrated to a handful of real anchor points, not fitted to a full match dataset. The Elo spread for the expanded field is a reasonable assumption, not a measured one. Real football has correlated shots, game state, red cards, and parked buses that a Poisson draw ignores. None of that is in here.</p><p>What the model does buy you is a clean, quantified intuition that survives its own assumptions: even if you halve the mismatch effect, expansion still meaningfully raises the goalkeeper-heroics rate. The direction is robust even where the exact multiplier is not. And the headline stays intact. Some of the 2026 goalkeeper boom is better goalkeeping. But a large, calculable chunk of it is just arithmetic. Invite more mismatches to the party and you will get more men in gloves having the night of their lives.</p><h3>Run it yourself</h3><p>The whole thing is about 150 lines of Python (NumPy plus Matplotlib). Change the save rate, the curve steepness, or the Elo spread, and watch the decomposition move. The assumptions are all in one block at the top, on purpose, so you can disagree with them precisely.</p><pre>python siege_curve.py</pre><p>Code and figures: <a href="https://github.com/pranavkumaarofficial/keeper">github.com/pranavkumaarofficial/keeper</a></p><p>If you want the human story behind the numbers, the 40-year-old journeyman who set all this off, I wrote that separately. And yes, I liked it enough that I turned him into a terminal tool that blocks dangerous commands in your coding agent, because a goalkeeper’s whole job is denying access. Both live in the same repo.</p><p><em>P.S Model and figures are original work, released under MIT. Source data via FIFA, Opta, ESPN, and FOX Sports Research, current as of the Round of 32, July 2026. This is a calibrated toy model, not a regression on a full dataset; assumptions are stated in the code so you can challenge them.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d13859f237e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I built a self-hosted app to share OTPs between family phones, encrypted end-to-end]]></title>
            <link>https://medium.com/@kumaarp.in/i-built-a-self-hosted-app-to-share-otps-between-family-phones-encrypted-end-to-end-7ff060c582d7?source=rss-ec1c8d359ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ff060c582d7</guid>
            <category><![CDATA[self-hosted]]></category>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Pranav Kumaar]]></dc:creator>
            <pubDate>Sun, 28 Jun 2026 13:20:21 GMT</pubDate>
            <atom:updated>2026-06-28T13:20:21.798Z</atom:updated>
            <content:encoded><![CDATA[<p><em>One npm dependency. 300 lines of server code. The relay can’t read your messages.</em></p><p>My mom ordered something on Amazon. The delivery guy showed up at my door asking for the OTP. The OTP was on her phone. She was in a meeting and couldn’t pick up.</p><p>If you live in India, you know this exact situation. Swiggy delivery, Flipkart OTP, bank verification code; it’s always on the wrong phone. You call, they don’t pick up, the delivery person is standing there staring at you.</p><p>I searched for a way to forward SMS between family phones. The apps on the Play Store (SMS Forwarder, AutoForward SMS) route your messages through someone else’s cloud in plaintext. Google Messages web ties one browser to one phone and dies if the phone loses signal. I didn’t find a single self-hosted SMS forwarding tool where the server can’t read the messages.</p><p>So I built one. It’s called otpilot, and it’s open source.</p><p>GitHub: <a href="https://github.com/pranavkumaarofficial/otpilot">https://github.com/pranavkumaarofficial/otpilot</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p5snHppZ12LNHHXScV_Lzw.png" /></figure><h3>What it does</h3><p>Every family member installs an Android app. When an OTP lands on any phone, the app encrypts it with AES-256-GCM and sends the ciphertext to a relay server on your home network — a Raspberry Pi, old laptop, NAS, anything. The relay pushes the ciphertext to every other phone and browser in real time. Everyone sees everyone’s OTPs, taps to copy, and the codes auto-delete after a few minutes.</p><p>The relay is a dumb pipe. It doesn’t have the encryption key. If you dumped its memory, you’d get gibberish. The key is generated in the browser and shared via QR code — it moves through the camera, not the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*2t81ik81cuuKC4RRv9f8eA.gif" /><figcaption>User Flow</figcaption></figure><h3>The tech stack is absurdly small</h3><p>The server is about 300 lines of Node.js. One npm dependency: ws for WebSocket. No Express, no database, no Redis.</p><pre>git clone https://github.com/pranavkumaarofficial/otpilot.git<br>cd otpilot<br>npm install   # installs exactly 1 package<br>npm start</pre><p>The web dashboard is a single HTML file. No React, no webpack, no build step. Vanilla JavaScript, the Web Crypto API for encryption, IndexedDB for local state. It’s a PWA — add it to your home screen and it works offline.</p><p>The whole project has one runtime dependency. I’ve seen node_modules with 800 packages for a todo app. This does end-to-end encrypted real-time messaging across multiple devices with ws and nothing else. I genuinely don&#39;t think I could cut it down further.</p><h3>How the encryption works</h3><p>When you create a family, the browser generates a 256-bit AES-GCM key using the Web Crypto API. That key never touches the server. It gets baked into a QR code, and other family members scan it with their camera. That’s the only time the key moves between devices.</p><p>Here’s the actual code that generates the key:</p><pre>async function generateKey() {<br>  const key = await crypto.subtle.generateKey(<br>    { name: &quot;AES-GCM&quot;, length: 256 }, true, [&quot;encrypt&quot;, &quot;decrypt&quot;]<br>  );<br>  const raw = await crypto.subtle.exportKey(&quot;raw&quot;, key);<br>  return btoa(String.fromCharCode(...new Uint8Array(raw)));<br>}</pre><p>Before any OTP leaves the phone, it gets encrypted:</p><pre>async function encrypt(data, keyB64) {<br>  const key = await importKey(keyB64);<br>  const iv = crypto.getRandomValues(new Uint8Array(12));<br>  const encoded = new TextEncoder().encode(JSON.stringify(data));<br>  const ct = await crypto.subtle.encrypt(<br>    { name: &quot;AES-GCM&quot;, iv }, key, encoded<br>  );<br>  return {<br>    iv: btoa(String.fromCharCode(...iv)),<br>    ct: btoa(String.fromCharCode(...new Uint8Array(ct)))<br>  };<br>}</pre><p>The Android app does the same thing in Kotlin:</p><pre>fun encrypt(plaintext: String, keyBase64: String): EncryptedPayload? {<br>    val keyBytes = Base64.decode(keyBase64, Base64.NO_WRAP)<br>    val key = SecretKeySpec(keyBytes, &quot;AES&quot;)<br>    val cipher = Cipher.getInstance(&quot;AES/GCM/NoPadding&quot;)<br>    cipher.init(Cipher.ENCRYPT_MODE, key)<br>    val iv = cipher.iv<br>    val ciphertextWithTag = cipher.doFinal(<br>        plaintext.toByteArray(Charsets.UTF_8)<br>    )<br>    return EncryptedPayload(<br>        iv = Base64.encodeToString(iv, Base64.NO_WRAP),<br>        ciphertext = Base64.encodeToString(<br>            ciphertextWithTag, Base64.NO_WRAP<br>        )<br>    )<br>}</pre><p>Both produce identical output. A message encrypted on an Android phone decrypts fine in the browser, and the other way around. This is the same cipher (AES-256-GCM) that Signal and WhatsApp use. On modern phones with hardware AES instructions, encryption takes under a millisecond.</p><p>The server receives { iv: &quot;...&quot;, ct: &quot;...&quot; } and passes it to everyone else. That&#39;s its entire job.</p><h3>Samsung phones broke everything (and how I fixed it)</h3><p>This ate most of my time.</p><p>Android has a SMS_RECEIVED broadcast. You register a receiver, SMS arrives, your app gets it. Works perfectly on Pixel, OnePlus, Xiaomi. On Samsung, silence. Nothing. Samsung blocks the SMS broadcast for any app that isn&#39;t the default messaging app. I discovered this after building the whole thing and testing on my actual phone.</p><p>The workaround: NotificationListenerService. When Samsung Messages or Google Messages gets an SMS, it posts a system notification. My app reads that notification. Samsung doesn&#39;t block this path.</p><p>But Samsung had another surprise. If the user has “hide sensitive notification content” enabled (lots of people do), the notification body says “Sensitive notification content hidden” instead of the actual text. So the app tries five fallback strategies to extract the real message:</p><ol><li>Standard notification extras (android.title, android.text, android.bigText)</li><li>tickerText — Samsung often leaves this unredacted</li><li>MessagingStyle messages — Google Messages stores full text here</li><li>InboxStyle textLines</li><li>android.subText and android.infoText</li></ol><p>In practice, tickerText or MessagingStyle works on every Samsung phone I’ve tested. If all five somehow fail, the app logs every notification extra it finds so I can figure out what Samsung changed this time.</p><h3>Onboarding in 30 seconds</h3><p>My mom needed to be able to do this. No terminal. No config files. No “paste this JSON into a .env.”</p><p>The admin creates a family:</p><ol><li>Open <a href="http://your-lan-ip:7890/">http://your-lan-ip:7890</a> in a browser</li><li>Type a family name and your name</li><li>A QR code appears with the relay address, family ID, join token, and encryption key packed into one blob</li></ol><p>Everyone else joins:</p><ol><li>Open the same URL on their phone</li><li>Tap “Join family”</li><li>Point their camera at the QR code</li><li>OTPs start showing up</li></ol><p>For SMS forwarding, install the Android APK, scan the same QR, grant notification access. The app runs in the background and forwards OTPs from that point on.</p><p>No accounts. No passwords. No email verification. You need to physically be in the same room (or send someone a screenshot) to join. That’s the security model — physical proximity for setup, AES-256-GCM for everything after.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*8aUI95GW8megn05JRZWWiA.gif" /><figcaption>It is literally this easy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*fbAQmQK1TyNlQP_9GtEXhg.gif" /><figcaption>Aaand this is how you manage family members too!</figcaption></figure><h3>The entire server fits in your head</h3><p>All server state lives in a JavaScript Map. No database, no file writes.</p><pre>const families = new Map();</pre><pre>function createFamily(name) {<br>  const id = &quot;f_&quot; + crypto.randomBytes(6).toString(&quot;base64url&quot;);<br>  const adminToken = crypto.randomBytes(24).toString(&quot;base64url&quot;);<br>  const joinToken = crypto.randomBytes(16).toString(&quot;base64url&quot;);<br>  families.set(id, {<br>    name, adminToken, joinToken, adminId: null,<br>    members: new Map(), otps: [], wsClients: new Map(),<br>    otpTtl: DEFAULT_OTP_TTL,<br>    stats: { totalOtps: 0 }<br>  });<br>  return { id, adminToken, joinToken };<br>}</pre><p>OTPs sit in an array. A timer runs every 30 seconds and throws out expired ones. Restart the server and everything is gone. That’s intentional — OTPs are disposable. They shouldn’t be stored anywhere.</p><p>When a WebSocket client connects, it gets the recent OTP history and member list. When a new OTP comes in over HTTP, the server broadcasts it to all connected clients for that family. The whole real-time layer is about 30 lines.</p><h3>Smart SMS filtering</h3><p>Personal messages don’t get forwarded. The app filters by keyword — it only picks up SMS containing “otp”, “code”, “pin”, “verification”, “delivery”, “parcel”, or “order” by default. You can change the keyword list in settings.</p><p>The OTP code itself gets extracted with a regex chain:</p><pre>const OTP_RE = [<br>  /\b(\d{4,8})\b.*(?:otp|code|pin|verification|verify)/i,<br>  /(?:otp|code|pin|verification|verify).*\b(\d{4,8})\b/i,<br>  /\b([A-Z0-9]{4,8})\b.*(?:otp|code|pin|verification|verify)/i,<br>  /(?:otp|code|pin|verification|verify).*\b([A-Z0-9]{4,8})\b/i,<br>  /\b(\d{6})\b/i,<br>];</pre><p>Numeric codes first, then alphanumeric (banks like HDFC send codes like “E9394”), then a fallback for any 6-digit number. The app also identifies the source — Amazon, Swiggy, Zomato, Uber, HDFC, SBI, and about 20 others — and color-codes the OTP card on the dashboard. Green for delivery, orange for food, teal for transport, red for banking.</p><h3>The real-time dashboard</h3><p>OTPs appear as cards. Each card shows the app name, the OTP code in big monospace text you can tap to copy, the SMS body, who it came from, when it arrived, and which family member’s phone received it. Cards have a colored left border by category.</p><p>A tab bar along the top lets you filter by family member. Each tab has a count badge and a green/grey dot showing who’s online. Members can see who the family admin is. When someone joins or leaves, everyone gets a notification.</p><h3>Self-hosting across different WiFi networks with Tailscale</h3><p>Here’s where most self-hosted tools fall apart. They assume all your devices are on the same WiFi. My mom is at her office. I’m at home. My sister is at college. Three buildings, three networks.</p><p>The usual advice: set up port forwarding, buy a domain, configure a reverse proxy. My mom is not doing any of that.</p><p>otpilot picks up Tailscale automatically. When the server starts, it scans the network interfaces, finds the Tailscale IP (100.x.y.z range), and puts it in the QR code. Each family member installs Tailscale on their phone — it’s a free app, one-tap setup — scans the QR, and they’re connected to the home relay from anywhere in the world. No port forwarding, no public IP, no DNS config.</p><p>The server prefers local IPs (192.168.x) when both are available, so traffic stays on your WiFi if everyone’s home. But the moment someone’s on a different network, Tailscale’s mesh takes over. The family doesn’t think about any of this. They scan a code and it works.</p><p>I haven’t found another open source SMS forwarding tool that does Tailscale auto-detection. Most either assume LAN-only or tell you to deploy to a cloud VPS, which defeats the whole point of running your own relay.</p><h3>When this is useful (and when it’s not)</h3><p>If you’re in an Indian household and you’re tired of calling your mom to read out Amazon OTPs, this fixes that. If you share a phone number at a small office and need to distribute verification codes, this works. If you want to forward SMS to another phone without a third party reading them, this is the tool.</p><p>It’s not going to work for you if you need iOS (Apple doesn’t let apps read SMS, full stop), if you don’t have a machine to run the server on (a Raspberry Pi is $35 and enough), or if you want to share OTPs with people outside your trust circle — everyone in the group sees everything.</p><h3>Try it</h3><pre>git clone https://github.com/pranavkumaarofficial/otpilot.git<br>cd otpilot<br>npm install<br>npm start</pre><p>Or docker compose up -d if you prefer containers.</p><p>The Android APK is on the GitHub releases page. Scan a QR code, grant notification access, and it starts forwarding.</p><p>MIT licensed. One dependency. The server can’t read your OTPs even if it wanted to.</p><p>GitHub: <a href="https://github.com/pranavkumaarofficial/otpilot">https://github.com/pranavkumaarofficial/otpilot</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ff060c582d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I built an OAuth debugger for FastAPI, so you don’t have to!]]></title>
            <link>https://medium.com/@kumaarp.in/i-built-an-oauth-debugger-for-fastapi-so-you-dont-have-to-1c5220273f3e?source=rss-ec1c8d359ab3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c5220273f3e</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Pranav Kumaar]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 17:16:50 GMT</pubDate>
            <atom:updated>2026-04-24T17:16:50.990Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Adding “Login with GitHub” to a FastAPI app should be a 5-minute task.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeihqb3qCiuBk9XD-VJLcw.png" /></figure><p>The OAuth 2.0 spec is 76 pages. Every tutorial I found used a different approach. Half of them were outdated, but most importantly: I needed to learn and understand this flow better. So I built a tool that does two things: drops working OAuth routes into any FastAPI project with one command, and shows you exactly what happens at every step of the flow.</p><p>It’s called oauth-for-dummies, and it’s open source. (Apologies for the naming convention)</p><p><strong>GitHub: </strong><a href="https://github.com/pranavkumaarofficial/oauth-for-dummies"><strong>https://github.com/pranavkumaarofficial/oauth-for-dummies</strong></a><strong><br>PyPI: </strong><strong>pip install oauth-for-dummies</strong></p><h3>What OAuth actually does</h3><p>OAuth is the protocol behind every “Login with Google” button. Instead of collecting a user’s password, you send them to Google (or GitHub, or Discord). They log in there, Google sends your app a temporary code, and your app exchanges that code for an access token. The token lets you read the user’s name and email. Their password never touches your server.</p><p>That’s the entire Authorization Code flow.</p><p>The implementation, though, involves five HTTP requests, three redirect hops, a CSRF token, and provider-specific quirks that no one warns you about. GitHub returns avatar URLs under avatar_url. Google uses picture. Discord stores avatars as hashes you have to reconstruct into CDN URLs. Microsoft doesn&#39;t return avatars from their user endpoint at all.</p><p>I kept running into these things. Every provider had some weird edge case, and I’d only discover it after the OAuth flow was already half-built.</p><h3>The problem with existing libraries</h3><p>There are good OAuth libraries for Python. Authlib has been around for years. python-social-auth supports dozens of providers.<em> fastapi-oauth2 gives you middleware you can drop in.</em></p><p>But they all share the same design: you install a package, call its API, and auth happens behind a wall. If something breaks (and with OAuth, something always breaks the first time), you’re debugging someone else’s abstraction.</p><p>I wanted to see the actual HTTP requests. What does the token exchange POST body look like? What is the provider sending back? Why is my callback returning a 400?</p><p>So I built a tool that generates the code directly into your project. No runtime dependency. You get the files, you own them, you can read every line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*S_7QSB9eggjfSN-EBAKhRQ.png" /></figure><h3>How it works</h3><p>Install it:</p><pre>pip install oauth-for-dummies</pre><p>Run the CLI inside your FastAPI project:</p><pre>cd your-project<br>oauth-init</pre><p>This creates four files:</p><pre>your-project/<br>  oauth_config.py       # Provider credentials from .env<br>  oauth_routes.py       # Login, callback, logout endpoints<br>  oauth_example_app.py  # Working demo app<br>  .env                  # Template for your OAuth keys</pre><p>Integrate into your existing app with two lines:</p><pre>from oauth_routes import router as oauth_router</pre><pre>app.include_router(oauth_router)</pre><p>That gives you /auth/{provider}/login, /auth/{provider}/callback, and /auth/logout for every provider you configure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eEyisEtubxwMvpz-zfVYCA.jpeg" /></figure><h3>Six providers, one pattern</h3><p>The project supports GitHub, Google, Discord, Spotify, Microsoft, and LinkedIn. Each provider follows the same flow but returns data in its own format. The scaffold normalizes everything for you.</p><p>Here’s the thing that actually ate my time when I was doing this manually. Every provider returns user data differently:</p><pre># GitHub returns:    {&quot;id&quot;: 123, &quot;name&quot;: &quot;...&quot;, &quot;avatar_url&quot;: &quot;...&quot;}<br># Google returns:    {&quot;id&quot;: &quot;456&quot;, &quot;name&quot;: &quot;...&quot;, &quot;picture&quot;: &quot;...&quot;}<br># Discord returns:   {&quot;id&quot;: &quot;789&quot;, &quot;avatar&quot;: &quot;a_hash123&quot;, ...}<br># Spotify returns:   {&quot;id&quot;: &quot;abc&quot;, &quot;display_name&quot;: &quot;...&quot;, &quot;images&quot;: [...]}<br># Microsoft returns: {&quot;id&quot;: &quot;def&quot;, &quot;displayName&quot;: &quot;...&quot;, &quot;mail&quot;: &quot;...&quot;}<br># LinkedIn returns:  {&quot;sub&quot;: &quot;ghi&quot;, &quot;name&quot;: &quot;...&quot;, &quot;picture&quot;: &quot;...&quot;}</pre><p>The _normalize_user function in the generated routes maps all of these into a consistent shape:</p><pre>{<br>    &quot;id&quot;: &quot;...&quot;,<br>    &quot;name&quot;: &quot;...&quot;,<br>    &quot;email&quot;: &quot;...&quot;,<br>    &quot;avatar&quot;: &quot;...&quot;,<br>    &quot;provider&quot;: &quot;github&quot;  # or &quot;google&quot;, &quot;discord&quot;, etc.<br>}</pre><p>You don’t have to figure out which field Discord uses for the display name (global_name vs username) or how to construct a Discord avatar URL from a hash. That&#39;s already done.</p><h3>The OAuth debugger</h3><p>This is the part I wish existed when I was learning OAuth.</p><p>The project includes a tutorial app with a built-in debugger called Learn Mode. Instead of silently redirecting you through the OAuth flow, it pauses at each step and shows you what’s happening.</p><p>Step 1 is the authorization request. You see the exact URL your app constructs, with every query parameter broken down: client_id, redirect_uri, scope, state, response_type. If PKCE is enabled, you also see the code_challenge and code_challenge_method.</p><p>Step 2 is the callback. After you authorize with the provider, you see the authorization code and state token your app received. The debugger shows the state verification (CSRF protection) happening in real time.</p><p>Step 3 is the token exchange. This is the server-to-server POST request that swaps the authorization code for an access token. You see the request body, the endpoint URL, and the response. Sensitive values like client_secret and access_token are partially redacted, but visible enough to understand the structure.</p><p>Step 4 is the user info request. The GET request to the provider’s user info API, with the Bearer token in the Authorization header. You see the raw JSON response, exactly as the provider sent it.</p><p>Step 5 is the normalized profile. How your app maps the provider-specific response into the standard user shape.</p><p>Each step has an expandable explanation underneath. No JavaScript frameworks, just &lt;details&gt; and &lt;summary&gt; tags.</p><p>To try it yourself:</p><pre>git clone https://github.com/pranavkumaarofficial/oauth-for-dummies.git<br>cd oauth-for-dummies<br>pip install -e .<br>cp .env.example .env<br># Add at least one provider&#39;s credentials to .env<br>uvicorn app.main:app --reload<br># Open http://localhost:8000 and click &quot;Learn Mode&quot;</pre><h3>PKCE support (OAuth 2.1)</h3><p>The project also supports PKCE, which stands for Proof Key for Code Exchange. It’s the main security improvement in the OAuth 2.1 draft.</p><p>Standard OAuth uses a client_secret during the token exchange. This works fine for server-side apps. But mobile apps and SPAs can&#39;t safely store a secret in client-side code. PKCE replaces the secret with a cryptographic challenge.</p><p>Here’s the flow:</p><ol><li>Your app generates a random string called a code_verifier (86 characters).</li><li>It hashes the verifier with SHA-256 and base64url-encodes the result. That’s the code_challenge.</li><li>The challenge goes with the authorization request.</li><li>The original verifier goes with the token exchange.</li><li>The provider hashes the verifier and checks it against the stored challenge.</li></ol><p>If someone intercepts the authorization code in transit, they can’t use it without the verifier. And the challenge from step 3 is a one-way hash, so intercepting that doesn’t help either.</p><p>Enable PKCE on any provider with one line:</p><pre># In the tutorial app<br>class MyProvider(OAuthProvider):<br>    use_pkce = True</pre><pre># In the scaffold<br>PKCE_PROVIDERS = {&quot;github&quot;, &quot;google&quot;}</pre><p>The actual implementation is about 15 lines:</p><pre>import hashlib<br>import base64<br>import secrets</pre><pre>def _generate_code_verifier() -&gt; str:<br>    return secrets.token_urlsafe(64)</pre><pre>def _generate_code_challenge(verifier: str) -&gt; str:<br>    digest = hashlib.sha256(verifier.encode(&quot;ascii&quot;)).digest()<br>    return base64.urlsafe_b64encode(digest).rstrip(b&quot;=&quot;).decode(&quot;ascii&quot;)</pre><p>The Learn Mode debugger shows PKCE parameters when enabled, so you can see the verifier and challenge values at each step.</p><h3>Security defaults</h3><p>The generated code includes security measures that are easy to get wrong when you’re implementing OAuth by hand.</p><p>The state parameter handles CSRF protection. A random token is generated before the redirect and verified on callback. If it doesn&#39;t match, the request is rejected. Session IDs are stored in HTTP-only cookies, so JavaScript can&#39;t access them. The cookies use SameSite=Lax to prevent cross-site request forgery. The client secret never reaches the browser because the code-for-token exchange happens entirely on your server. Sessions expire after one hour by default, but the max_age value is configurable.</p><p>The session store is in-memory (a Python dict). For production, you’d swap it for Redis or a database. For development, it works without any extra setup.</p><h3>Getting your OAuth credentials</h3><p>Each provider has a developer portal where you register your app and get a client ID and secret. The process is roughly the same everywhere: create an app, set the callback URL, copy the credentials.</p><p>For GitHub, go to github.com/settings/developers and create an OAuth App. Set the callback URL to <a href="http://localhost:8000/auth/github/callback.">http://localhost:8000/auth/github/callback.</a></p><p>For Google, go to console.cloud.google.com/apis/credentials. Create an OAuth Client ID for a Web application. The redirect URI is <a href="http://localhost:8000/auth/google/callback.">http://localhost:8000/auth/google/callback.</a></p><p>Discord is at discord.com/developers/applications. Create an application, go to OAuth2, and add http://localhost:8000/auth/discord/callback as a redirect.</p><p>Spotify is at developer.spotify.com/dashboard. Create an app and add the redirect URI <a href="http://localhost:8000/auth/spotify/callback.">http://localhost:8000/auth/spotify/callback.</a></p><p>For Microsoft, go to portal.azure.com and register an application with the redirect URI <a href="http://localhost:8000/auth/microsoft/callback.">http://localhost:8000/auth/microsoft/callback.</a></p><p>LinkedIn is at linkedin.com/developers/apps. Create an app, go to the Auth tab, and add <a href="http://localhost:8000/auth/linkedin/callback.">http://localhost:8000/auth/linkedin/callback.</a></p><p>Copy the Client ID and Client Secret into your .env file. Only configure the providers you actually want. Unconfigured ones don&#39;t show up in the UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eEyisEtubxwMvpz-zfVYCA.jpeg" /></figure><h3>When to use this (and when not to)</h3><p>This is a good fit if you want OAuth working in your FastAPI app quickly, you want to understand what the code is doing, or you’re building a prototype or internal tool and don’t want a runtime dependency on an auth library.</p><p>It’s not the right tool if you need 20+ providers, enterprise SSO with SAML, or a production auth system handling millions of sessions. For that, look at Authlib or a managed service like Auth0.</p><p>I’m not trying to replace those. oauth-for-dummies fills the gap between “I have no idea how OAuth works” and “I need a production auth system.” Most projects start in that gap. I know I did.</p><h3>Try it</h3><pre>pip install oauth-for-dummies<br>oauth-init</pre><p>Or clone the repo and run the tutorial app with the debugger:</p><pre>git clone https://github.com/pranavkumaarofficial/oauth-for-dummies.git<br>cd oauth-for-dummies<br>pip install -e .<br>cp .env.example .env<br>uvicorn app.main:app --reload</pre><p>MIT licensed. If you want to add a provider (Twitter/X, Apple, Facebook, Twitch) or help with Flask support, PRs are open.</p><p><strong>GitHub: </strong><a href="https://github.com/pranavkumaarofficial/oauth-for-dummies"><strong>https://github.com/pranavkumaarofficial/oauth-for-dummies</strong></a><strong><br>PyPI: </strong><a href="https://pypi.org/project/oauth-for-dummies/"><strong>https://pypi.org/project/oauth-for-dummies/</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c5220273f3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>