<?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 Anurag Mewar on Medium]]></title>
        <description><![CDATA[Stories by Anurag Mewar on Medium]]></description>
        <link>https://medium.com/@anuragmewar?source=rss-88a7beb8e854------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_MohjiqHo7J-qtAwx23N0Q.png</url>
            <title>Stories by Anurag Mewar on Medium</title>
            <link>https://medium.com/@anuragmewar?source=rss-88a7beb8e854------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 12:13:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anuragmewar/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[How I Tricked OpenClaw Into Attacking Its Own Network: A NAT64 SSRF Bypass]]></title>
            <link>https://infosecwriteups.com/how-i-tricked-openclaw-into-attacking-its-own-network-a-nat64-ssrf-bypass-9b93a7f11cd9?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b93a7f11cd9</guid>
            <category><![CDATA[ssrf]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[openclaw]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Sat, 12 Sep 2026 15:27:56 GMT</pubDate>
            <atom:updated>2026-09-17T04:44:32.007Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A story about how a single misread pair of bytes let a public-looking IPv6 address secretly point at 169.254.169.254.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iALALRadhr7OOgTsxoXc9A.png" /></figure><h3><em>An AI assistant with keys to your whole network</em></h3><p><a href="https://openclaw.ai/">OpenClaw</a> (previously known as Clawdbot and Moltbot) runs on your devices, answers you on the channels you already use, speaks and listens on your phone and your computer, and grows with you over time. With millions of active users, and thousands of endpoints running it as an always-on gateway.</p><p>Read that again with a security hat on. “Always-on,” “runs on your devices,” “answers on the channels you already use”. That means OpenClaw’s gateway is a long-lived process sitting inside your trust boundary (on your laptop, on a home server, or on a cloud box next to your other infrastructure). And one of the interesting features that should make any security conscious individual sit up straight: “the assistant can fetch URLs on your behalf”.</p><p>The web_fetch tool lets the agent go grab a web page. Image attachments in the chat completions API get downloaded server-side. Inbound channel messages can carry media URLs that the gateway resolves and pulls. Every one of those is the assistant reaching out to the network from inside your perimeter, using your machine’s network position.</p><p>That is the exact shape of a Server-Side Request Forgery (SSRF) primitive. If an attacker can convince the assistant to fetch a URL of the attacker’s choosing, and that URL resolves to something internal (your router’s admin panel, a database bound to localhost, or the crown jewel of cloud SSRF, the metadata endpoint at 169.254.169.254) then the attacker just borrowed your server’s identity to reach places they should never be able to touch.</p><p>The OpenClaw team knew this. That’s why they built an SSRF guard.</p><h4><em>The guard, and the thing it was guarding against</em></h4><p>The whole point of the guard is simple to state: before the gateway connects to any resolved address, block anything private, internal, loopback, link-local, or otherwise special-use. Resolve the hostname, look at every IP it points to, and if any of them is 127.0.0.1, or 10.x, or 169.254.x, or a carrier-grade-NAT metadata address, refuse the request and throw.</p><p>The tricky part isn’t blocking 127.0.0.1. Anyone can block a plain dotted-quad. The tricky part is that IPv6 gives an attacker a dozen ways to smuggle an IPv4 address inside an IPv6 literal. There are IPv4-mapped addresses (::ffff:127.0.0.1), 6to4, Teredo, ISATAP, and the NAT64 / IPv4-embedded transition prefixes. A serious guard has to decode the embedded IPv4 out of each of those forms and check that, not just the IPv6 wrapper.</p><p>OpenClaw’s guard does exactly this. It has a function called extractEmbeddedIpv4FromIpv6, whose entire job is to pull the real IPv4 out of these transition formats so the guard can judge the true destination. It leans on a well-respected library, ipaddr.js, to classify which transition format each address belongs to.</p><p>And that is where the bug lived (not in a missing check), but in a correct-looking one that read the wrong bytes.</p><h4><em>The moment it clicked</em></h4><p>The guard grouped two different NAT64 formats into a single case and decoded both of them the same way by reading the last 32 bits of the address.</p><p>For the famous NAT64 prefix (the well-known 64:ff9b::/96), reading the last 32 bits is exactly right. That’s where the embedded IPv4 lives. But ipaddr.js folds a second, larger prefix into the same classification: the RFC 8215 locally-assigned NAT64 prefix 64:ff9b:1::/48. And in that format, per RFC 6052, the embedded IPv4 does not live in the last 32 bits. It lives up front, split across bits 48-63 and 72-87, with a reserved byte in the middle. So the guard, for any 64:ff9b:1::/48 address, was reading the wrong end of the address entirely. If the guard reads the trailing bits to decide “safe or not safe”, and those trailing bits are an ignored suffix that a real NAT64 router doesn’t even route on, then an attacker gets to put two different addresses into one IPv6 literal:</p><ul><li>A private, internal target in the real embedded slot (bits 48-63 + 72-87): the address the NAT64 gateway will actually forward to.</li><li>A benign public decoy (say, Google’s 8.8.8.8) in the trailing bits: the only thing the guard ever looks at.</li></ul><p>The guard sees 8.8.8.8, shrugs, and opens the gate. The router forwards to 169.254.169.254. The address, quite literally, lied.</p><h4><em>Why this is dangerous</em></h4><p>Given a crafted /48 literal, the guard always misreads it and always returns the decoy verdict. No timing, no race, no luck.</p><p>The end-to-end SSRF here has one precondition: the host running OpenClaw has to have an actual RFC 8215 64:ff9b:1::/48 NAT64 gateway on its network, because something has to actually forward the crafted address to the private target. On a host with that NAT64 setup, an authenticated user could steer web_fetch, image-URL ingestion, and inbound media fetches at internal and cloud-metadata endpoints (straight through a guard that was specifically built to stop exactly that).</p><h3><em>Science behind the bypass</em></h3><p>Now the fun part. Let’s build the lying address, bit by bit, and see precisely why the guard was fooled.</p><h4>How NAT64 embeds an IPv4 address (RFC 6052)</h4><p>NAT64 lets IPv6-only clients talk to IPv4-only servers. To do that, the IPv4 address gets embedded inside an IPv6 address using a special prefix. The layout has a deliberate hole in it. Bits 64-71 form a reserved u-byte that must be zero. The IPv4 octets flow around that hole. For a prefix length of 48, RFC 6052 says the 32-bit IPv4 address “a.b.c.d” is placed like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiLpFTAJeojrduBdybX6uA.png" /><figcaption>Crafted literal</figcaption></figure><p>In the green rows, the suffix bits are ignored<strong>.</strong> RFC 6052 explicitly requires translators to treat any nonzero suffix as something to disregard. That is the property the attack abuses: the suffix is a place you can write anything and a compliant NAT64 router won’t care.</p><h4>The guard’s fatal shortcut</h4><p>Here’s the essence of what OpenClaw’s guard did: it asked ipaddr.js to classify the address, and for the rfc6052 class it read the trailing two hextets:</p><pre>case &quot;rfc6145&quot;:<br>case &quot;rfc6052&quot;:<br>  // decode IPv4 from the LAST 32 bits - parts[6] and parts[7]<br>  return decodeIpv4FromHextets(parts[6], parts[7]);</pre><p>The problem is upstream. ipaddr.js (v2.4.0) classifies two subnets as rfc6052:</p><pre>rfc6052: [<br>  [new IPv6([0x64, 0xff9b, 0, 0, 0, 0, 0, 0]), 96],   // well-known  64:ff9b::/96<br>  [new IPv6([0x64, 0xff9b, 0x1, 0, 0, 0, 0, 0]), 48],  // RFC 8215   64:ff9b:1::/48<br>],</pre><ul><li>For the /96 prefix, the IPv4 really is in the trailing 32 bits. Reading parts[6] / parts[7] is correct.</li><li>For the /48 prefix, the IPv4 is in bits 48–63 + 72–87 (hextets 3, 4, 5). The trailing bits (parts[6] / parts[7]) are the ignored suffix. Reading them is not just wrong; it’s reading attacker-controlled scratch space.</li></ul><h4><em>Building the lying address</em></h4><p>Let’s construct the literal that pins 169.254.169.254 (the AWS/GCP-style link-local metadata address) while showing the guard a friendly 8.8.8.8.</p><ul><li>Target (real): 169.254.169.254 → octets [169, 254, 169, 254] → hex [0xa9, 0xfe, 0xa9, 0xfe]</li><li>Decoy (shown to guard): 8.8.8.8 → octets [8, 8, 8, 8] → hex [0x08, 0x08, 0x08, 0x08]</li></ul><p>Now place the target octets in the RFC 6052 /48 slots, and the decoy in the ignored suffix:</p><pre>hextet[0] = 0x0064  ---&gt;  /48 prefix<br>hextet[1] = 0xff9b  ---&gt;  /48 prefix<br>hextet[2] = 0x0001  ---&gt;  /48 prefix  (this is what makes it the RFC 8215 /48)<br>hextet[3] = 0xa9fe  ---&gt;  IPv4 bytes 0,1<br>hextet[4] = 0x00a9  ---&gt;  u-byte(0) : IPv4 byte 2<br>hextet[5] = 0xfe00  ---&gt;  IPv4 byte 3 : (suffix)<br>hextet[6] = 0x0808  ---&gt;  Ignored suffix (guard reads)<br>hextet[7] = 0x0808  ---&gt;  Ignored suffix (guard reads)</pre><p>Join them: 64:ff9b:1:a9fe:a9:fe00:808:808</p><p>That single literal is the whole exploit. Let’s trace what each side sees.</p><p><strong>What a compliant NAT64 router sees (decodes per RFC 6052 /48):</strong></p><ul><li>byte 0 = high(0xa9fe) = 0xa9 = 169</li><li>byte 1 = low(0xa9fe) = 0xfe = 254</li><li>byte 2 = low(0x00a9) = 0xa9 = 169 (the 0x00 u-byte is discarded)</li><li>byte 3 = high(0xfe00) = 0xfe = 254</li></ul><p>This is 169.254.169.254 (the cloud metadata endpoint).</p><p><strong>What the vulnerable guard saw (reads trailing 32 bits, parts[6] / parts[7]):</strong></p><ul><li>0x0808 = 8.8</li><li>0x0808 = 8.8</li></ul><p>This is 8.8.8.8 (a normal public address).</p><h3><em>Why I Find This Beautiful</em></h3><p>A missing SSRF check is not difficult to find: a scanner flags it, a reviewer notices the fetch has no guard. But this guard was thorough. It decoded IPv4-mapped, 6to4, Teredo, ISATAP, the well-known NAT64 prefix (a genuinely careful piece of defensive code). It just trusted a library’s classification to imply a single memory layout, and that assumption was false for one of the two subnets folded under a shared label.</p><p>That’s where the interesting vulnerabilities live now: not in the absence of security controls, but in the seams between two systems that almost agree. The guard and the NAT64 router both understand the same address (they just parse it differently), and the attacker lives in the gap. It’s a parser-differential bug wearing a high-risk SSRF costume.</p><p>And the abused property was a design feature of the standard: RFC 6052 mandating that suffix bits be ignored. That mandate is what created the free scratch space for a decoy. The standard did its job; the implementation just read the wrong half of the address.</p><h3><em>Timeline and affected versions</em></h3><p><strong>What to do: </strong>update your OpenClaw instance to the latest version. That’s it. The fix is out and every current release has it, so updating closes this completely.</p><p><strong>A little more detail:</strong></p><ul><li>The fix is shipped. It landed in v2026.8.1 and is in every release since. If you’re on a recent version, you already have it.</li><li>The bug was there for a stretch of older versions (definitely the beta builds from 2026.7.2-beta.1 to 2026.8.1-beta.2, and possibly some stable versions before that). I’m still working out the exact list with the OpenClaw team, and I’ll update this once it’s settled.</li><li>You don’t need to wait for that list. Whatever version you were on before, updating to the latest fixes it. No other action needed.</li></ul><p>Big thanks to the OpenClaw team (they confirmed the high severity SSRF quickly and pushed the fix to everyone). The only thing left to sort out is which old versions to officially mark as affected; the hole itself is already closed for anyone on a current build.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hk0S4BFpy7NU53Kf5ycJ3Q.png" /></figure><blockquote><em>Patched here: </em><a href="https://github.com/openclaw/openclaw/pull/123241"><em>https://github.com/openclaw/openclaw/pull/123241</em></a></blockquote><h3>Takeaways for defenders</h3><p>If you build or review SSRF guards, three things from this report are worth carrying forward:</p><p>1. Decode every transition format to its true destination, and confirm the layout (don’t infer it from a classification label). A library saying “this is NAT64” doesn’t tell you which NAT64 layout, and the byte positions differ by prefix length.</p><p>2. Beware ignored / reserved bits. Anywhere a protocol says “these bits don’t matter”, an attacker will put something that does matter to your parser but doesn’t matter to the thing that actually routes.</p><p>3. Write tests with adversarial encodings, not just honest ones. A test that only exercises the well-behaved layout will validate a decoder that reads the wrong bytes (because on honest input, the wrong bytes happen to hold the right answer). The crafted-decoy case is the one that tells the truth.</p><p>As always, if you’d like to chat more about solving security problems, AI, APIs, or tech in general; <a href="https://www.linkedin.com/in/anurag-mewar-3226bb163/">hit me up on LinkedIn</a>. My DMs are always open :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b93a7f11cd9" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/how-i-tricked-openclaw-into-attacking-its-own-network-a-nat64-ssrf-bypass-9b93a7f11cd9">How I Tricked OpenClaw Into Attacking Its Own Network: A NAT64 SSRF Bypass</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Here’s how Postman Agent Mode hacks for me]]></title>
            <link>https://anuragmewar.medium.com/heres-how-postman-agent-mode-hacks-for-me-789cfb419656?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/789cfb419656</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Tue, 26 May 2026 14:48:08 GMT</pubDate>
            <atom:updated>2026-05-26T14:48:08.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZrCYBlHi1bhU2e6hynOyw.png" /></figure><p>Code is shipping faster than it ever has. AI assistants are writing the first draft of pull requests on most teams I talk to. Meanwhile the security-review side of the house hasn’t kept up. The tools we have today can mostly detect lexical bugs (SQL injection, hardcoded secrets), but stop short of catching anything that requires deep understanding of what the code is supposed to do.</p><p>Full manual security review at this scale is impractical, so we need a good system to match the velocity. This article is about how I tried to solve that by leveraging the same platform where you live and breathe APIs. See how a similar approach can slot into your secure development stack.</p><h3>Why semantic issue detection is the hard one?</h3><p>If you’ve been doing API security for a while, you already know: the OWASP API Top 10 leans hard on authorization bugs. <strong>API1 (BOLA)</strong>, <strong>API3 (BOPLA)</strong>, and <strong>API5 (BFLA), </strong>this accounts for somewhere between 1/2 and 3/4th of real-world API breaches depending on whose telemetry you trust.</p><p>The reason these issues persist isn’t that engineers don’t know about them. It’s that they’re <strong><em>semantic</em></strong>. To detect “non-admins can invite users,” a tool needs to understand:</p><ul><li>What the endpoint is <strong><em>supposed</em></strong> to do (only admins should be able to invite): the intent</li><li>What the endpoint <strong><em>actually</em></strong> does (it accepts any team member): the implementation</li><li>That those two facts <strong><em>disagree</em></strong>: the drift between intent and implementation</li></ul><p>That’s not a lexical pattern. There’s no regex for “this handler is missing a role check.” A DAST scanner hitting POST /teams/team-alpha/invites with a viewer token and getting a 201 sees a healthy response. It has no idea the contract expects admin-only. A SAST scanner reading the same handler sees a perfectly normal authentication check; the absence of a role comparison isn&#39;t wrong-looking, it&#39;s just absent.</p><p>Intent is the missing input. And intent, for most teams, lives in their head, in their spec, or in a wiki page nobody updates. That’s why these bugs keep showing up.</p><h3>The pipleline</h3><p>Before we get to the demo, the setup is worth pausing on, because the prerequisites are doing a lot of the heavy lifting. This pattern works well for API-first teams that have an API spec maintained in the repo, with semantic annotations for security intent (x-required-role, x-required-membership, x-rate-limit, or even disciplined description).</p><p>The API spec is sometimes missing, but for AI-age teams shipping new services, spec-first is increasingly the default because AI assistants do better work when given a spec to anchor on.</p><blockquote>I should be honest:<strong> </strong>If your API spec is stale, this pattern surfaces that as drift , which is itself useful information, but it’ll be noisy until you fix the spec.</blockquote><h4>Here’s what I used</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*II6GBJDTLn79zCZabHFLbg.png" /><figcaption>Delivery mechanism</figcaption></figure><ul><li>Skill #1 (custom built), <strong>endpoint-discovery</strong>, reads the API spec (for intent), the source code (framework-level parsing), and the functional Postman collection (optional). For each identified endpoint the skill captures three views: intent, implementation, exercised, and then runs drift checks between them. Anywhere the intent disagrees with the implementation, the skill writes to the discrepancies array (structured drift findings tagged with OWASP categories and severities). Output is a single endpoints.json.</li><li>Skill #2 (custom built), <strong>security-threat-model</strong>, consumes that inventory and drift finding (endpoints.json), and writes two artifacts:<br>1. security-test-plan.yaml: declarative test plan. One suite per endpoint. Each case names an actor, a request, an expected outcome, and (where applicable) the specific drift finding it was derived from. <br>2. postman-agent-brief.md: the natural-language prompt for Postman Agent mode to generate security test collection based on the security test plan generated.</li><li><a href="https://www.postman.com/product/agent-mode/"><strong>Postman Agent mode</strong></a> with <a href="https://learning.postman.com/docs/agent-mode/native-git"><strong>native git</strong></a> to read those skills + artifacts directly from the local code repo, and generate security test collections</li><li><strong>Postman collections</strong> as the runnable “security contract” versioned, designed to perform live security testing, and later as a regression check for continuous security monitoring using <strong>Postman monitors</strong>.</li></ul><h4>The demo</h4><p>For the demo, I developed an application with /health, /auth/login, /me, and GET /teams/{teamId}/invites already on main. On a feature branch (feat/team-invites), I added a new POST /teams/{teamId}/invites. The spec is annotated honestly (x-required-role: admin), plus description that says &quot;Only admins can issue invites&quot;,. The implementation, in classic Friday-afternoon style, checks team membership but forgets the role check, and accepts a role field in the request body. That&#39;s API5 BFLA and API3 BOPLA in the same endpoint. A viewer can create an invite at admin level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*5MNgAesENuV4BtolfitYYQ.png" /><figcaption>Diff between intent and imlementation</figcaption></figure><p>The Postman desktop client has its Agent mode pointed at the repo via native git. With this, Postman Agent reads SKILL.md files, source code, the spec, and the generated artifacts directly from the code repository (local files in our demo).</p><h4>#1 Starting state on main</h4><p>Working tree is clean. security/artifacts/ doesn&#39;t exist yet (these are generated, not committed).</p><h4>#2 Create the feature branch and introduce the bug</h4><p>The new POST handler does the membership check but skips the role check in a new feature branch.</p><h4>#3 Prompt Postman Agent Mode to audit the branch</h4><p>Switch to Postman desktop. Open the Agent Mode panel. Native git is already configured against this workspace path; Agent mode will use LLM to orchestrate. Prompt something like: <em>“Audit my changes for security drift, then author the security contract collection per the brief.&quot;</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YnNFgmudRflfBNTvJExiUQ.gif" /><figcaption>Artifacts generated for Postman Agent Mode</figcaption></figure><h4>#4 Agent Mode invokes the endpoint-discovery skill</h4><p>Agent Mode reads .claude/skills/endpoint-discovery/SKILL.md, matches the prompt to its description, and runs the helper script via its shell tool.</p><h4>#5 First artifact appears: endpoints.json</h4><p>The skill emits security/artifacts/endpoints.json. Five endpoints inventoried. Four drift findings, two of them high-severity on the new POST endpoint. This will be further validated by next skill.</p><p>The headline finding inside that file:</p><pre>{<br>  &quot;type&quot;: &quot;INTENT_VS_IMPL&quot;,<br>  &quot;field&quot;: &quot;checksRole&quot;,<br>  &quot;expected&quot;: &quot;admin&quot;,<br>  &quot;actual&quot;: false,<br>  &quot;owaspCandidate&quot;: &quot;API5_BFLA&quot;,<br>  &quot;severity&quot;: &quot;high&quot;,<br>  &quot;rationale&quot;: &quot;Spec declares x-required-role: admin but the handler never compares membership.role.&quot;<br>}</pre><p>A second finding flags the role enum in the request body: API3 BOPLA, mass-assignment risk. Together, those two are the full privilege escalation path.</p><h4>#6: Agent Mode chains to the security-threat-model skill next</h4><p>Without re-prompting. Agent Mode sees in the first skill’s SKILL.md that security-threat-model is the natural next step, reads its SKILL.md, and runs the required steps.</p><p>security/test-accounts.yaml is the meta file that can be defined by security team inside of code repository. It will be read by the security-threat-model skill along with security/artifacts/endpoints.json for output generation. security/test-accounts.yaml will cover test account (all roles) meta information like: there&#39;s an admin in team-alpha called admin_team_alpha, a viewer in team-alpha called viewer_team_alpha, and an admin in team-beta called admin_team_beta. Each entry has an id, username, tenant, role. No passwords (those are in the Postman vault).</p><p>For each endpoint, the skill considers several case categories and emits the ones that apply. The actor selection rule for example:</p><p><strong>non_admin_blocked</strong> (the BFLA case): emitted whenever intent.requiredRole is set on a state-mutating endpoint. Actor: <strong>findLowPrivInTenant(focalTenant)</strong>: picks an account in the focal tenant whose role is below the required role. For the invites endpoint requiring admin, that&#39;s viewer_team_alpha.</p><h4>#7: Second wave of artifacts: security test plan + Agent Mode brief</h4><p>Two new files appear in security/artifacts/:<em>security-test-plan.yaml and </em><em>endpoints.json</em></p><p>The plan is declarative, one suite per endpoint, each test case named in plain English with the OWASP code attached. The two cases that will fail on the vulnerable server:</p><pre>- id: non_admin_blocked<br>  name: &quot;Non-admin (viewer) must NOT be able to POST<br>         /teams/{teamId}/invites — only admins are authorized&quot;<br>  owasp: API5_BFLA<br>  severity: high<br>  derived_from: [INTENT_VS_IMPL/checksRole]</pre><pre>- id: non_admin_cannot_escalate<br>  name: &quot;viewer must NOT be able to escalate by submitting<br>         role=\&quot;admin\&quot; - privilege escalation via mass assignment&quot;<br>  owasp: API3_BOPLA<br>  severity: high<br>  derived_from: [BODY_ACCEPTS_PRIV_FIELD/role]</pre><h4>#8: Agent Mode reads the brief and authors the security collection</h4><p>Agent Mode picks up postman-agent-brief.md, applies the structure it specifies, and writes a new security Postman collection in the current workspace. Setup folder logs in three test accounts using environment variables; three endpoint folders below it carry 13 test requests total, with OWASP codes in the names.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ys9WQxAM5O4h5IQrxjReZw.gif" /><figcaption>Security test collection generated by Postman Agent Mode</figcaption></figure><h4># 9: Run the security collection against the vulnerable server</h4><p>Using an environment variable file containing appropriate test credentials, run the collection. Two failures. Both contain the OWASP code in their name; a reviewer reading the runner output knows the category, and the severity.</p><h4># 10: Use this security collection as a continuous security contract test monitor</h4><p>The same collection now stays in the workspace as the regression contract via Postman Monitors. If any future code change breaks role-gating, you will be able to detect without re-testing everything. This will ensure you have healthy and secure APIs running in production.</p><h3>Going further</h3><p>The next moves using the similar system can make this fully autonomous as per your use-case. The skills can be designed per your infrastructure, and can also run cleanly in CI using GitHub Action on every new PR. Same flow, no human handholding, institutional teeth instead of &quot;remember to run this&quot;.</p><p>The shape (readable contract plus agent enforcement on every change) generalizes well beyond APIs and authZ. The same pattern can work for IaC policy drift, for data-classification labels on new fields, for SBOM compliance on new dependencies, for secrets scanning, and for any security control where the rule is checkable but the per-PR human-review cost has become prohibitive.</p><p>As always, if you’d like to chat more about solving security problems, AI, APIs, or tech in general; <a href="https://www.linkedin.com/in/anurag-mewar-3226bb163/">hit me up on LinkedIn</a>. My DMs are always open :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=789cfb419656" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Code Dependencies Stole Your Secrets: Strengthening a Modern NPM Supply Chain]]></title>
            <link>https://anuragmewar.medium.com/your-code-dependencies-stole-your-secrets-strengthening-a-modern-npm-supply-chain-part-1-a8096cdbd886?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8096cdbd886</guid>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[supply-chain]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 14:00:25 GMT</pubDate>
            <atom:updated>2026-05-15T07:42:09.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OEO67HFsfGYpYCIqUgL1pw.png" /></figure><p>Supply chain security is in a weird place. On one hand, NPM is incredibly powerful: millions of packages, easy publishing, easy reuse. On the other hand, it’s a giant graph of “who depends on whom” plus a lot of implicit trust. And that trust is exactly what modern malware loves abusing!</p><p>Recently, we’ve seen campaigns like Shai-Hulud / Shai-Hulud 2.0 where attackers gained access to maintainer credentials, slipped malicious code into seemingly normal packages, and relied on the fact that: <em>If you trust package ‘A’, you implicitly trust everything ‘A’ depends on, and everything those things depend on, and so on.</em></p><h3>The Shai-Hulud Attack Model</h3><p>At a high level, Shai-Hulud-style attacks exploit three facts:</p><ol><li><strong>Maintainer access is everything: </strong>With access to a maintainer’s NPM token, one can publish new versions of existing packages, add new transitive dependencies, and even push code that runs during installation</li><li><strong>Install-time scripts are powerful:</strong> Lifecycle scripts like preinstall, install, postinstall run before the app ever starts. They run with the environment of CI / dev machines, can read process.env, and reach the filesystem</li><li><strong>Semver and lockfile hygiene decide who gets owned: </strong>If you depend on &quot;^1.0.0&quot; and don’t pin versions or respect lockfiles, a new malicious version can slide in. If CI pipelines do npm install without a lockfile, they’re essentially opting into “latest compatible version, even if it’s malicious”</li></ol><p>Shai-Hulud 2.0 took advantage of exactly this: compromised maintainer → new malicious versions → install scripts run in sensitive environments → secrets harvested and additional packages compromised.</p><h3>Building a Miniature NPM Supply Chain and Then Poisoning It</h3><p>Let’s look at the demo that captures this in a contained environment. The idea is that you can use the same mental model to design defenses. In this lab, you will find a local private NPM registry (Verdaccio), benign packages under the @shworm-lab/* scope, a demo “victim app”, a realistic compromise where a package gets weaponized, a preinstall based worm that steals secrets from the environment and drops loot.</p><blockquote>Project Github Repo: <a href="https://github.com/5h4d0wr007/shworm-lab">https://github.com/5h4d0wr007/shworm-lab</a></blockquote><h4>Components</h4><p>We use three big pieces:</p><p><strong>Private Registry</strong></p><ul><li>A local Verdaccio instance at <a href="http://localhost:4873/">http://localhost:4873</a></li><li>Scoped packages under @shworm-lab/*</li><li>Authentication via htpasswd (so we can model “maintainer tokens” and “CI tokens”)</li></ul><p><strong>Actors / Identities</strong></p><ul><li>dev-maintainer: the developer/maintainer identity used to publish packages</li><li>ci-bot: the CI / automation identity used by the victim app to install packages</li></ul><p><strong>Packages / Apps</strong></p><ul><li>shworm-lab/core-loggerv1.0.0: benign logging package. v1.1.0: compromised logger with a malicious preinstall hook</li><li>@shworm-lab/feature-libv1.0.0 : benign business library that depends on core-logger</li><li>victim-app:depends only on @shworm-lab/feature-lib</li></ul><h4>Watching the Attack Play Out</h4><ul><li>Start Verdaccio at <a href="http://localhost:4873/">http://localhost:4873</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UC5g97SSbUnXUD_uqf-vfA.png" /><figcaption>Verdaccio launched via docker-compose</figcaption></figure><ul><li>Create dev-maintainer and ci-bot accounts with tokens</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KXM7MoY2b5vU_9ZVcw2YqQ.png" /><figcaption>“dev-maintainer” added to the user DB. Same for “ci-bot”</figcaption></figure><ul><li>[Benign] Publish @shworm-lab/core-logger@1.0.0 (no lifecycle scripts)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1d3LDr10_jGTrk03NR-qw.png" /><figcaption>Benign version v1.0.0 published for “core-logger”</figcaption></figure><ul><li>[Benign] Publish @shworm-lab/feature-lib@1.0.0 with dependency: &quot;@shworm-lab/core-logger&quot;: &quot;^1.0.0&quot;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sx12eEvTZ1F-eCp_GHfs1g.png" /><figcaption>“feature-lib” published with “core-logger” as dependency</figcaption></figure><ul><li>[Benign] victim-app depends on @shworm-lab/feature-lib@^1.0.0 and installs it using ci-bot</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fUvNsvKTyz7-AezdBlwbIA.png" /><figcaption>“victim-app” depends on “feature-lib”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ensahTY7-nBmpH6pnoO8vw.png" /><figcaption>NPM token of “ci-bot” used by the “victim app”</figcaption></figure><ul><li>Attacker steals dev-maintainer token</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dcp709CwQmIT6X7RhuoA1w.png" /><figcaption>“victim-app” state before the compromise</figcaption></figure><ul><li>[Compromised] Attacker publishes @shworm-lab/core-logger@1.1.0 with a preinstall script</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcHq2LjRq5oweLb0WmAllg.png" /><figcaption>New version of “core-logger” published by the attacker</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYpJ7xPnDxNhBx2I7ns86Q.png" /><figcaption>v1.1.0 is the malicious version published for “core-logger”</figcaption></figure><ul><li>[Benign] feature-lib is unchanged; it still depends on ^1.0.0</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7uucltxQgrgIB20xnQekg.png" /></figure><ul><li>[Infection Starts] victim-app does a fresh install (new CI job, new dev machine, etc)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PizeY-X7JYt2cg-Qa7wKRQ.png" /><figcaption>Intentionally removed package-lock.json to mimic direct installation of the malicious version by the “victim app”</figcaption></figure><ul><li>[Compromised] Resolver picks core-logger@1.1.0 as the latest matching ^1.0.0</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZG6eimK1qmSslII48n3rMQ.png" /><figcaption>“victim-app” picked the new version of core-logger v1.1.0 (which is compromised) because lock file is missing</figcaption></figure><ul><li>[Compromised] During npm install, preinstall runs in CI/dev environment. It scrapes environment variables containing TOKEN, KEY, SECRET, etc</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iEU5u_mWu6gGwUXcmrPYdA.png" /><figcaption>Dummy secrets for loot demo</figcaption></figure><ul><li>[Compromised] Drops loot into .shworm-telemetry/ in the project root: env-snapshot.json: actual secrets. telemetry-report.json: metadata about what was found</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKa19RMUuqcTmRXvwqtCrg.png" /><figcaption>The loot</figcaption></figure><blockquote><strong>Note:</strong> The victim app never changed its code. The only thing that changed was a new version of the dependency of another dependency ;)</blockquote><h3>Security Controls: How Do We Defend Against This?</h3><p>A modern supply-chain attack succeeds when multiple safeguards across source, build, release, and consumption fail or are missing. But when we combine small, well-designed controls at each layer, we can dramatically reduce both the likelihood and blast radius of supply-chain attacks. To defend, we need layered hardening that apply uniformly regardless of whether a project uses NPM, PNPM, or Yarn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dGesuQIO6EhhJ44UvUuBPw.png" /><figcaption>100% yes!</figcaption></figure><p>Here’s the full-stack defense map covering the most practical controls to reduce supply-chain risk end-to-end:</p><h4><strong>#1. Maintainer Identity &amp; Credential Security</strong></h4><p>The most fundamental defense is securing the identities that can publish packages, because publish capability (whether via a token or an authorized CI identity) becomes a trust root for downstream consumers. Access tokens explicitly grant the ability to install and publish packages, and modern workflows increasingly rely on CI identities to publish securely.</p><p>In practice, many supply-chain incidents begin with compromised publisher credentials or compromised release automation, enabling attackers to ship a trojanized update through otherwise normal package channels.</p><p>For organizations, strong identity security typically means centralizing control of who can publish and how publishing is authorized: enforce MFA on the accounts that can publish, restrict publish rights to a small set of maintainers, and prefer CI-based publishing where the workflow itself is the trusted publisher. <a href="https://docs.npmjs.com/trusted-publishers">NPM now supports Trusted Publishing via OIDC</a>, which allows publishing directly from CI/CD using OpenID Connect and avoids distributing long-lived NPM tokens to humans.</p><p><strong>In a secure setup:</strong></p><ul><li>Avoid storing publish credentials on developer machines; prefer CI-based publishing with Trusted Publishing where possible</li><li>If tokens are used, keep them only in CI/secret managers, and rotate them frequently</li><li>Use a dedicated automation identity for publishing (separate from individual developer accounts) to reduce blast radius and improve auditability</li></ul><p>Where your tooling supports it (including registries and CI platforms), prefer short-lived, job-bound credentials (OIDC) over long-lived secrets. This reduces token leakage risk because credentials are tied to a specific workflow execution and are not reusable outside it.</p><h4>#2 Publishing Workflow Controls</h4><p>CI/CD systems build trusted artifacts, and hold powerful credentials. This class of attacks often leverages install-time execution within CI environments to harvest secrets, because CI pipelines frequently have more privileges than any individual developer.</p><p>A modern secure publishing workflow is CI-driven rather than developer-laptop-driven. Developers propose changes via pull requests, and CI is responsible for producing and releasing artifacts.</p><p><strong>In practice, a hardened publish pipeline includes:</strong></p><ul><li>Reproducible builds for integrity, so the published artifact matches reviewed source code every time (to prevent “out-of-band injection”)</li><li>Static analysis (not linting; security-oriented inspection) of source and built artifacts. E.g., Shai-Hulud-style attacks are visible statically: so anything like scanning package.json for new/changed lifecycle scripts, scanning JS files for: process.env, child_process, etc</li><li>Provenance generation (prefer attestation over regular signing) for solving “mystery publish” problems. It helps in linking the published package back to a specific CI workflow and commit. This is crucial for detection, response, and policy enforcement (e.g., assert “only our CI can publish”)</li><li>Controlled publish credentials using NPM Trusted Publishing (OIDC)</li></ul><p>During publishing, CI must avoid exposing secrets during dependency installation. Dependency installation (npm install), if possible, should happen in a no-secrets environment, forcing any malicious lifecycle scripts to run without access to high-value credentials. Secrets should only be injected in later stages, once dependencies have been installed safely. E.g.,</p><pre>steps:<br>  - name: Install dependencies<br>    run: npm install<br><br>  - name: Publish<br>    env:<br>      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}<br>    run: npm publish            </pre><p>Publishing should be tied to a dedicated automation identity and constrained by workflow rules.</p><p><strong>Supporting controls include:</strong></p><ul><li>Allowing only protected branches to trigger publish workflows</li><li>Requiring multiple reviewers for package changes</li><li>Enforcing signed commits at least for critical packages</li><li>Attaching build provenance metadata (In npm’s ecosystem, provenance is implemented as attestations), either explicitly (npm publish --provenance) or implicitly via Trusted Publishing (OIDC)</li></ul><p><strong>Note: </strong><a href="https://github.blog/security/supply-chain-security/strengthening-supply-chain-security-preparing-for-the-next-malware-campaign/">GitHub and NPM just announced an accelerated security roadmap</a> focused on hardening the publication phase, with bulk OIDC onboarding to help organizations migrate large numbers of packages to Trusted Publishing, expanded OIDC provider support beyond GitHub Actions and GitLab, and a new staged publishing model that introduces a review window before packages go live. Staged publishing, with MFA-verified approval from package owners, directly addresses the class of incidents where unintended or malicious changes reach downstream users too quickly. Taken together, these changes reinforce the idea that publishing should be a controlled, auditable, and CI-bound process.</p><h4>#3 Registry-Level Protections</h4><p>A registry is the distribution hub for dependencies. Public npmjs.com serves a shared, open ecosystem, which means it generally does not provide organization-specific policy enforcement. While NPM supports features like provenance metadata and Trusted Publishing, it does not block lifecycle scripts at install time, nor does it allow organizations to enforce mandatory signing/provenance or quarantine specific versions based on their own internal policies. As a result, many organizations treat public npm as a source of truth for open packages, but not as the enforcement boundary.</p><p>Private registries and internal proxies fill this gap by acting as a policy firewall. Organizations often route internal package consumption through these registries, where they can apply controls before packages reach developers or CI systems.</p><p><strong>Example registry-level controls:</strong></p><ul><li>Enforcing provenance/signature verification, where supported, before accepting or promoting packages</li><li>Blocking or gating packages that introduce lifecycle scripts (preinstall, install, postinstall)</li><li>Quarantining packages or versions flagged by policy or scanning rules</li><li>Freezing or locking specific versions to prevent unwanted upgrades</li><li>Mirroring public NPM packages after scanning them</li><li>Maintaining strict RBAC for publishing and promotion rights</li></ul><h4>#4 Dependency Resolution Controls in Applications</h4><p>Semver surprises are a common and often underestimated risk in JavaScript supply chains. Even with secure publishing, applications must consume dependencies safely. Shai-Hulud-style attacks can propagate in environments that use semver ranges like ^1.0.0 and perform fresh dependency resolution, allowing newer compatible versions (including malicious ones) to be pulled in automatically.</p><p>The most critical defense here is strict lockfile usage combined with npm ci(“clean install”). npm ci requires lockfile, uses lockfile exactly, and fails on mismatch. Lockfiles ensure that the dependency graph remains deterministic. Without a lockfile (or when it is deleted or regenerated), NPM must re-evaluate semver ranges and may fetch newer compatible versions. This creates a primary window through which malicious updates can propagate.</p><p>Applications should treat changes to package.json and lockfiles like code changes. Dependency upgrades should undergo pull-request review, during which reviewers inspect for things like:</p><ul><li>new or changed lifecycle scripts</li><li>new dependencies</li><li>unexpected changes in package size or signs of obfuscation</li><li>changes in package ownership or publishing identity (where observable)</li></ul><p>Version pinning is highly recommended. Instead of &quot;@company/packagename&quot;: &quot;^1.0.0&quot;, use exact versions such as &quot;@company/packagename&quot;: &quot;1.0.0&quot;. This eliminates the possibility of automatic, unintentional upgrades.</p><h4>#5 CI/CD Runtime Behavior Controls</h4><p>Lifecycle scripts (preinstall, install, postinstall) are incredibly powerful. They execute during dependency installation, before application code runs and before consumers can meaningfully inspect installed artifacts. These scripts run with the privileges and environment of the installing process, which in CI often includes access to sensitive credentials.</p><p>You should consider disabling lifecycle scripts during dependency installation by default. For example, this can be done with npm install --ignore-scripts or by setting ignore-scripts=true in .npmrc. This prevents install-time code execution entirely.</p><p>If your build requires lifecycle scripts (for example, when building native modules), treat this as an explicit exception rather than the default. Such packages should be reviewed and allowlisted through process or tooling, rather than enabling lifecycle scripts globally. This should be combined with secret minimization. Further reduce risk by separating CI jobs:</p><ul><li><strong>Job 1:</strong> Install dependencies (no secrets, no tokens)</li><li><strong>Job 2:</strong> Build and test (minimal secrets, if required)</li><li><strong>Job 3:</strong> Deploy or publish (restricted secrets only)</li></ul><p>This isolation removes the attacker’s primary incentive by preventing access to secrets during install-time execution.</p><h4>#6 Monitoring, SBOM, and Behavioural Detection</h4><p>Detection mechanisms complement preventive controls and are critical for identifying suspicious behaviour when attackers bypass upstream safeguards. Organizations increasingly rely on a combination of visibility and detection techniques, including:</p><ul><li>SBOM generation and drift detection to track and compare dependency graphs over time</li><li>Static scanning of package tarballs for suspicious APIs, metadata changes, and newly introduced lifecycle scripts</li><li>Behavioral sandboxes that simulate npm install in isolated environments to observe unusual filesystem or network activity (typically applied to higher-risk packages)</li><li>Install-time telemetry or monitoring to detect unexpected outbound connections or writes to sensitive directories</li></ul><p>These techniques help surface suspicious changes even if publish-time or registry-level controls are bypassed.</p><h4>#7. Organizational Culture &amp; Governance</h4><p>Technical defenses are weakened when developers treat dependency updates as trivial or allow uncontrolled publishing. To make supply-chain protections effective over time, organizations should instill a culture of:</p><ul><li>Treating dependencies as executable code, and not passive configuration</li><li>Applying two-person review to critical package releases or updates</li><li>Maintaining a clear ownership model for internal libraries and shared components</li><li>Training developers on the risks like semver ranges and install-time scripts</li><li>Reviewing dependency diffs in pull requests with the same level of scrutiny as application code, especially for high-impact dependencies</li></ul><p>These cultural and governance practices ensure that technical controls remain effective, understood, and consistently applied as teams and codebases evolve.</p><h3>What’s Next?</h3><p>Controls are only useful if they’re enforceable. Most teams don’t have time to manually diff every dependency bump or inspect every tarball. In Part 2, we will see supply-chain gate that helps detect (and prevent) the kinds of attack behaviour we simulated.</p><p>As always, if you’d like to chat more about security, or tech in general; <a href="https://www.linkedin.com/in/anurag-mewar-3226bb163/">hit me up on LinkedIn</a>. My DMs are always open :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8096cdbd886" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart API Security: The Power of Postman MCP and LLMs]]></title>
            <link>https://anuragmewar.medium.com/smart-api-security-the-power-of-postman-mcp-and-llms-48d52f53480f?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/48d52f53480f</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 03:58:05 GMT</pubDate>
            <atom:updated>2026-05-27T07:57:55.747Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2OK0TRnf1gGOd7zj_di1Q.png" /></figure><blockquote>What if AI could read your OpenAPI spec, understand security implications, generate Postman security test collections dynamically, and execute them against a live server; all automatically within your CI/CD pipeline?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TgsmxNFJXMKnVVOpTYi1fQ.gif" /><figcaption>Final Validated Findings are Posted</figcaption></figure><p><strong>Note: </strong>This article has been moved to Postman’s official blog site. Please access it here: <a href="https://blog.postman.com/engineering/smart-api-security-the-power-of-llms-and-postman-mcp">https://blog.postman.com/engineering/smart-api-security-the-power-of-llms-and-postman-mcp</a></p><p>If you’d like to chat more about security, tech, or anything about this project in general; <a href="https://www.linkedin.com/in/anurag-mewar-3226bb163/">hit me up on LinkedIn</a>. My DMs are always open :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48d52f53480f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Hacking Systems for Fun to Securing Millions: My Journey Through Both Sides of the Firewall]]></title>
            <link>https://anuragmewar.medium.com/from-hacking-systems-for-fun-to-securing-millions-my-journey-through-both-sides-of-the-firewall-60c842120797?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/60c842120797</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Thu, 18 Sep 2025 15:02:23 GMT</pubDate>
            <atom:updated>2025-09-18T15:02:23.965Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“You can run a side business of finding and reporting bugs — and become a millionaire.”</blockquote><p>That’s what one of my college professors told me. At the time, I had no idea just how deep I’d fall into the rabbit hole of hacking — and how that curiosity would eventually lead me to helping secure software used by millions today.</p><p>If you’ve ever watched <em>Mr. Robot</em>, you’re probably familiar with the phrase: “security engineer by day, and a vigilante hacker by night”. On screen, Elliot lived a double life — breaching systems in the shadows and maintaining software security by daylight. It felt dramatized, but that duality hits close to home. When you move from being outside, hacking into companies, to being inside one, protecting assets and users, you realize just how different the work really is. This story is for anyone who’s ever wondered what it’s like on both sides of the firewall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tWZoHpKp35MUxDMn" /><figcaption>Ingress Curiosity, Egress Responsibility</figcaption></figure><h4>The First Real Adrenaline Hit</h4><p>It was summer break. Our semester results had just been released, and I was checking my grades. Our college used a third-party service to let students view their grades, personal data, and even edit sensitive fields like bank account details — meant for later graduation refunds.</p><p>Something odd caught my attention. The results flow opened in a new browser window — a sandboxed view — through a URL that had a suspiciously encoded query parameter. Out of instinct, I fired up my proxy and began inspecting the traffic. The parameter was base64-encoded twice. When decoded, it revealed a strange pattern:</p><p>&lt;sixNumbers&gt;+&lt;sixChars&gt;=&lt;encryptedString&gt;</p><p>The numbers matched parts of my own student ID. Weird. But the encryption looked messy, and honestly, I was about to drop it… until a college friend from different engineering branch later mentioned that he received an unfairly low grade for a group project. I was now curious to see — what if I can see other students’ details?</p><p>Later that night, the curiosity returned with full force. I explored more and found a POST request in the profile section — again using a similar query parameter format. But this time, it only had the &lt;sixChars&gt;=&lt;encryptedString&gt; structure.</p><p>I crafted a new parameter using the format I’d seen earlier: I took the first three and last three digits of my friend’s student ID, combined them, and replaced the encrypted value with his full ID in plain text. The request returned a 5XX error — a sign I was onto something.</p><p>I then noticed the “encrypted” value didn’t behave like real encryption. After some basic decoding attempts, I discovered it was just a ROT10 obfuscation of a string with our college name and three extra characters. It didn’t appear to be tied to any session.</p><p>I started further tampering, swapping out parameters using my friend’s student ID. The response changed — slightly. Then I altered the HTTP verb from POST to GET… and boom. The server responded with a new window — the same sandbox-style view — showing my friend’s full profile. Grades, PII, bank details, everything. And it was editable!</p><p>Not just his — I found out I could access any student’s data. Current students. Alumni. Everyone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*eJqSquorCExb1RVg2PbOcQ.png" /><figcaption>One hack. Dozens of messages 👀</figcaption></figure><p>At that moment, I knew I was holding something serious. Faculty and staff used the same service for admin access.</p><h4>A Responsible Disclosure That Stuck With Me</h4><p>I knew this was serious. I drafted a report and sent it to our college’s IT team. They escalated it to the third-party vendor, who later invited me to verify their staging fix. It wasn’t just fun anymore. It felt impactful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b_N54r-RSybg9ioz60AZjg.png" /><figcaption>Acknowledgement for various college ‘hacks’</figcaption></figure><p>That spark pushed me to go further. In fact, it even got a little… mischievous. I later helped a friend “win” the ‘Mr. Final Year’ election at college. The application tracked votes per candidate, per department — higher the count, higher the chances of winning. One of my friends from my department was a candidate. Let’s just say I found a way to “nudge” the vote count using the app’s exposed logic and poor request validation. Yeah, you don’t always stay within the boundaries of legality and ethics when you’re still figuring it all out — but I promise I didn’t go too far 😉.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*AP2FLWbqtWssmX89-NJpag.png" /><figcaption>The only thing that worried me was to ensure current votes are ≤ total number of eligible voters :)</figcaption></figure><p>Within months, I was hacking other college systems — e-learning system (powered by a major global platform), library portal (built on a popular open source stack), e-cell (Innovation and Entrepreneurship) app, website, and even parts of other university at places like MIT, Harvard, Cambridge, UC Berkeley and Drexel.</p><h4>Hunting Bugs, Collecting Cool Swags, and Scoring Bounties</h4><p>After those initial university hacks, things escalated quickly.</p><p>I started hacking on private and public bug bounty programs run by some of the world’s biggest companies.</p><p>Sometimes it was a box of Red Bull crate at my doorstep. Other times, it was fancy t-shirts, hoodies, or some slick swags with company logos I admired. And yes — there were bounties too. Real money. I was hooked. The thrill of hacking, combined with the recognition, made the experience addictive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YadYVujfbmxJS0YRmn4C2w.jpeg" /><figcaption>Rocking BBC InfoSec tee at ‘the hacker underground’</figcaption></figure><p>There was even an instance where the company wasn’t running a bug bounty program — just a disclosure program. I reported a critical data leak involving internal support tool access. Their program manager reached out to let me know that while the company’s bug bounty program wasn’t live yet, they had decided to award a monetary bounty right away. That experience reinforced something important: if you act in good faith, good things do come back around — often multiplied. Keep the grind on!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2TVP-IjQnMUX81klBU15Pw.gif" /><figcaption>This is me figuring out the only hardening done on this public kiosk was the plastic casing ;)</figcaption></figure><h4>What Real-World Security Engineering Looks Like</h4><p>Security is often romanticized as catching bad actors and hunting bugs — and while those moments are real (and exciting), I believe the real beauty lies in the engineering aspect of it. When you’re inside, you’re no longer solving puzzles in isolation — you’re protecting real users, real systems, and a real business. Security engineering is where creativity, technical depth, and responsibility come together.</p><p>As a security engineer, you’re immersed in the full lifecycle of a product. You develop both broad and deep technical insight into how features are designed, how services are built, and how infrastructure operates at scale. That means working from code to cloud with product specs, codebases, architecture diagrams, and cloud environments — all with the goal of identifying risks early and shaping secure design from the start.</p><p>You’ll conduct threat modeling sessions, review sensitive changes, perform audits, perform VAPTs, and partner with engineering teams to drive remediation. Security engineers help define secure development guidelines, build and integrate tools that let developers move fast — without cutting corners. The goal isn’t to slow things down. It’s to scale confidence.</p><p>You might find yourself building internal tooling, writing scripts to detect unusual behavior, or investigating anomalies. Maybe you’re helping coordinate a third-party pentest, or performing an internal penetration test. And yes — bug bounties stay in the picture. Only now, you’re the one managing the program: defining scope, engaging with hackers, validating reports, and making sure the right teams fix the right things at the right time.</p><p>Security engineering isn’t about gatekeeping. It’s about enabling. Enabling teams to move fast without cutting corners. Enabling the company to grow without compromising its users. Enabling security to scale — with automation, with education, and with the mindset that security is a shared responsibility.</p><p>And beyond the code, you’ll play a role in the broader ecosystem of the company — governance, compliance, vendor risk, internal red/blue teaming, audit support, and even shaping policy around new tech trends like LLMs and AI threats right now.</p><p>The problems are deeper. The impact is broader. The stakes are higher. And the wins? They’re worth it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Gz7AEjFMzB9qX1J-KQTMHQ.jpeg" /><figcaption>Grateful to have received this award directly from our CEO during Postman’s first-ever company-wide offsite in Europe — celebrating 10 years of Postman</figcaption></figure><h4>Still Hacking, Just On the Inside</h4><p>At Postman, we’ve run multiple company-wide internal security bug hunting events — where anyone in the org can join the game. The thrill of hacking doesn’t disappear when you step inside a right company; it just evolves. Now, you’re solving high-impact problems with better tools, better access.</p><p>Developers bring a unique advantage: deep product knowledge and context, which often leads to identifying logic-specific issues. With cool swags and awards as motivation, these initiatives help reinforce a strong culture of security — built on the belief that “<em>security is a shared responsibility”</em>. And what’s even better? You get to collaborate with some of the most thoughtful and sharp minds across the company — each bringing unique perspectives and skill sets to the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6LOTUUsUDDIQc_EECRonA.png" /><figcaption>A screenshot from our last internal bug hunting event. Friendly competition, serious impact</figcaption></figure><h4>From Submitting Reports to Reviewing Them: Leading Postman’s Bug Bounty Program</h4><p>At Postman, security is our top priority — we take it very seriously to ensure we maintain the trust of our users. While we aim to keep things rock solid through internal security reviews and secure development practices, we acknowledge that no system is ever 100% secure. That’s why we operate a private bug bounty program with HackerOne.</p><p>Funny how things come full circle. The same drive that pulled me into bug bounties is now helping me run one. At Postman, I lead our HackerOne bug bounty program, working closely with external researchers and hackers from around the world. Being on both sides of the table gives a unique perspective.</p><p>Here’s what I’ve learned from the best hackers in our program:</p><ul><li>They <strong>communicate clearly</strong> — not just “XSS in endpoint,” but how it can affect real users, what’s the blast radius, and how it can be chained.</li><li>They <strong>think like engineers</strong> — they understand frameworks, cloud services, authentication flows, and look for logic flaws.</li><li>They <strong>go deep</strong> — instead of hopping across different scopes, they pick one target and stick with it. They read documentation, understand how the product works, helping them identify not-easy-to-detect issues — like business logic.</li><li>They <strong>act with empathy</strong> — staying in scope, working with us professionally to make Postman secure for everyone.</li></ul><p>We invite skilled and passionate researchers from around the world to submit vulnerabilities through our program and reward them generously for impactful findings. Today, we offer up to $7,500 USD per valid submission, depending on severity and impact. Beyond that, we run bounty multiplier campaigns, launched a CTF challenge with HackerOne in the past for security researchers to reward creativity. These events have helped drive deeper engagement and build long-term partnerships with the hacking community.</p><p>And we’re constantly improving — we are also considering the idea of a public program that will be open to everyone by default. Until then, if you have something to report, or want to participate, you can always reach out at <strong>security@postman.com</strong> or visit our disclosure page here: <a href="https://www.postman.com/trust/security/vulnerability-reporting">https://www.postman.com/trust/security/vulnerability-reporting</a></p><p>If you’ve got ideas, suggestions, or even just want to connect, my DMs are always open.</p><h4>Advice for New Security Enthusiasts</h4><p>I started out as a student developing and exploiting APIs for fun. Now, I’m helping build the most secure API platform out there— learning every day from the best developers and hackers.</p><p>If you’ve ever felt that rush from uncovering a vulnerability — or from solving tricky puzzles again and again — that spark of adrenaline might just be your sign. The journey ahead could surprise you.</p><p>Feel free to <a href="https://www.linkedin.com/in/anurag-mewar-3226bb163/">shoot me a message on LinkedIn</a> about anything security — I’m usually around and always up for a good chat.</p><p>Stay curious — and most importantly, stay ethical!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60c842120797" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hack your APIs using Postman]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://anuragmewar.medium.com/hack-your-apis-using-postman-2ed24d987d47?source=rss-88a7beb8e854------2"><img src="https://cdn-images-1.medium.com/max/1536/1*rfqZVnWVgG-ko5ngaIcZMA.png" width="1536"></a></p><p class="medium-feed-snippet">This article serves as a public article based on my private TryHackMe room, &#x201C;POSTmanipulate&#x201D;&#x200A;&#x2014;&#x200A;learn how to use Postman as your ultimate&#x2026;</p><p class="medium-feed-link"><a href="https://anuragmewar.medium.com/hack-your-apis-using-postman-2ed24d987d47?source=rss-88a7beb8e854------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://anuragmewar.medium.com/hack-your-apis-using-postman-2ed24d987d47?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ed24d987d47</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-security]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Thu, 01 May 2025 12:17:15 GMT</pubDate>
            <atom:updated>2025-05-01T12:17:19.470Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[OAuth Authorization and Authentication: The Holy Grail of Application Security]]></title>
            <link>https://anuragmewar.medium.com/oauth-authorization-and-authentication-the-holy-grail-of-application-security-c2e05773bfb?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2e05773bfb</guid>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Wed, 14 Feb 2024 07:22:46 GMT</pubDate>
            <atom:updated>2024-02-14T07:22:46.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*Sh-WdLa_R1heF8FFadcKXA.jpeg" /><figcaption>AI Generated Computer Hacker at Work</figcaption></figure><h3>OAuth Unwrapped</h3><p>OAuth, short for Open Authorization, is a widely adopted authorization framework that simplifies the process of granting applications limited access to user data while keeping their login credentials safe. With additional support, OAuth also serves as a reliable mechanism for authentication, allowing users to log in using their existing accounts from different services like Google.</p><p>Imagine an OAuth system as checking into a hotel. When you arrive, the person at the front desk asks for your ID and reservation proof, and in return, they give you a key card. This key card allows you to enter your hotel room, use the gym, and access other facilities within the hotel. Interestingly, when you swipe the key card at your room door or the gym entrance, the door doesn’t need to know who you are; it simply recognizes the valid key card and grants access. In this analogy, the person at the front desk represents the Authorization Server. They verify your identity and issue you the key card (Access Token). Your hotel room and other amenities represent the Resource Server, holding the resources you can access. The key card can be restricted to certain areas (mapped to specific hotel doors), ensuring it can only open authorized places — just like OAuth allows access tokens to be scoped and used for specific resources.</p><h3>A Brief History of OAuth</h3><p>We’ll delve into the fascinating history of OAuth, tracing its origins and understanding how it has developed into the widely adopted authorization framework we know today.</p><p>In the early days of the internet, sharing passwords with third-party applications was a typical but flawed practice. It posed security risks and limited user control over their accounts. To address this issue, a group of companies developed OAuth 1.0. However, as technology advanced, OAuth 1.0 proved challenging to implement in emerging use cases like mobile applications. And this led to the development of OAuth 2.0, built from scratch, and aimed to simplify and enhance OAuth 1.0 while adapting to the evolving needs. OAuth 2.0 emerged as an open framework, offering a secure and standardized method for authorization across web, mobile, and desktop applications. OAuth started with the goal of protecting users from third-party apps, but its usefulness expanded to various scenarios — which we’ll cover later in this article.</p><h3>OAuth Working: Roles</h3><p>OAuth 2.0 involves the collaboration of four distinct roles.</p><ul><li><strong>Resource Owner (User):</strong> the User who owns the protected resources. They can grant Applications access to their resources.</li><li><strong>Client (Application):</strong> represents the Application that wants to access the Resource Owner’s protected resources. The Client initiates the OAuth flow and requests permission from the Resource Owner to access their resources.</li><li><strong>Authorization Server:</strong> the Resource Owner interacts with this when the Client requests access to their account. It displays the OAuth prompt, where Resource Owner can approve/deny the Client’s request. Upon successful verification, it is also responsible for issuing Access Token that the Client can use to access the protected resources.</li><li><strong>Resource Server:</strong> hosts the protected resources the Client wants to access. It also validates the Access Token received from the Client. If the Access Token is valid and the Resource Owner has allowed permission, the Resource Server provides the requested resources to the Client.</li></ul><h3>OAuth Working: Scopes</h3><p>Scopes in OAuth provide a way to define and limit access to the necessary information required by the Application. Including the scope parameter in the authorization request limits the issued Access Token to the permissions granted. The format of the scope names can vary significantly between different OAuth providers. When used for authentication, the standardized OpenID Connect scopes (E.g., scope=openid profile email phone) provide User verification.</p><h3>OAuth Working: Grant Types/Flows</h3><p>OAuth 2.0 defines several grant types, also called flows (i.e., sequence of steps involved in the process), to accommodate different use cases and security requirements.</p><p>The four well-known grant types are:</p><h4><strong>Authorization Code</strong></h4><p>This is the most commonly used flow for server-side applications and arguably the most secure direct OAuth flow. It involves exchanging an Authorization Code for Access Token; and is suitable for Applications that can securely store Client Secrets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S8S5WcuulzUz4MT5cBPp0w.png" /><figcaption>Authorization Code Flow</figcaption></figure><p>Let’s explore an example where the Application needs to access User’s Gmail account APIs to provide custom updates.</p><p><strong>Steps Involved:</strong></p><ol><li><strong>User Accesses the Application:</strong> The User attempts to access the Application.</li><li><strong>Application Redirects to Authorization Server:</strong> The Application redirects the User to the Authorization Server, in this case, the Google Authorization Server. The request includes the desired scope of access.</li><li><strong>User Authenticates and Gives Consent:</strong> After authenticating with the Google Authorization Server, the User is presented with the requested scopes and asked to give consent. The User can further grant or deny access to their Gmail account.</li><li><strong>Authorization Server Provides Authorization Code:</strong> If the User grants access, the Google Authorization Server generates an Authorization Code and redirects the User back to the Application’s designated redirect URI along with the Authorization Code.</li><li><strong>Application Requests Access Token:</strong> The Application receives the Authorization Code and requests the Google Authorization Server to exchange it for the Access Token. This request includes the Application credentials (client ID and client secret) and the Authorization Code.</li><li><strong>Authorization Server Validates and Issues Access Token:</strong> The Google Authorization Server validates the Authorization Code and Client credentials. If the validation is successful, it generates the Access Token and returns it to the Application.</li><li><strong>Application Accesses Protected Resources:</strong> The Application can now use the received Access Token to make API requests to the Resource Server (Gmail).</li><li><strong>Resource Access Granted:</strong> With successful API calls to the Resource Server, the Application is granted access to the desired resources. The User can now fully use the Application as intended.</li></ol><h4><strong>Implicit</strong></h4><p>In this flow, the Access Token is returned directly in the response from the authorization endpoint. The Implicit grant is considered less secure than the Authorization Code grant and not recommended for modern Applications. Unlike the Authorization Code flow, all communication between the Client and the Authorization Server occurs via the browser. This means sensitive data is not passed via a secure back channel, introducing potential security risks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NoaxEb1F5WgEw5ctY1NmJg.png" /><figcaption>Implicit Flow</figcaption></figure><p><strong>Steps Involved:</strong></p><ol><li><strong>User Accesses the Application:</strong> The User attempts to access the Application.</li><li><strong>Application Redirects to Authorization Server:</strong> The application redirects the User to the Authorization Server. The request includes the desired scope of access.</li><li><strong>User Authenticates and Gives Consent:</strong> After authenticating with the Authorization Server, the User is presented with the requested scopes and asked to give consent. The User can further grant or deny access to the requested account.</li><li><strong>Authorization Server Provides Access Token:</strong> If the User grants access, the Authorization Server will immediately generate Access Token and redirect the User.</li><li><strong>Application Accesses Protected Resources:</strong> The Application can now use the Access Token to make API requests to the Resource Server. Unlike the Authorization Code flow, the communication happens via the front channel (browser).</li><li><strong>Resource Access Granted:</strong> With the successful verification of the token, the Application is granted access to the desired resources. The User can now fully use the Application as intended.</li></ol><h4><strong>Password</strong></h4><p>The Application collects the User credentials (username and password) to obtain the Access Token. As it requires the Application to handle user credentials (which OAuth aims to prevent), this grant type goes against the principles of OAuth and is not recommended for use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jy3ru_D_7Th14nP6M1ihRQ.png" /><figcaption>Password</figcaption></figure><h4><strong>Client Credentials</strong></h4><p>This is employed when the Application needs to request the Access Token to access its resources (rather than acting on behalf of a User). This is used for machine-to-machine communication and is one of the simplest grants because no User or browser is involved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CzngDHCxhjSAeKVo9ZAhBQ.png" /><figcaption>Client Credentials</figcaption></figure><blockquote>Each flow has security considerations and usage scenarios; choosing the appropriate flow is essential. Please refer to security best practices for OAuth: <a href="https://oauth.net/2/oauth-best-practice/">https://oauth.net/2/oauth-best-practice/</a></blockquote><h3>OAuth for Authentication</h3><p>Authentication, the process of verifying the identity of a User/System, is a vital component of any Application. While OAuth 2.0 is primarily an authorization framework, it has been widely adopted for authentication flows. One common workaround is to have an endpoint to retrieve the authenticated User’s name, profile information, or other relevant data.</p><p>OpenID Connect (OIDC), an OAuth 2.0 extension, offers a more standardized and robust approach to authentication. In the forthcoming sections, we will delve into the details of OIDC and explore how it enhances authentication capabilities.</p><h4>SSO</h4><p>OAuth 2.0 enables Single Sign-On (SSO) capabilities, allowing users to sign in to multiple services with a single set of credentials. Once authenticated with the Identity Provider (IdP), services can be accessed without the need to re-authenticate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*peRPCg90kHlZ1uYAsvPhTQ.png" /><figcaption>SSO Protocols</figcaption></figure><p>It is essential to know that SSO will employ different protocols, such as Security Assertion Markup Language (SAML) or OpenID Connect (OIDC), to facilitate the authentication process. These protocols enable the exchange of authentication assertions or tokens between the IdP and Service Providers (SPs) participating in the SSO system.</p><h4>Sign in with Google</h4><p>Sign in with Google is a prevalent authentication flow that allows users to quickly and securely sign in to the Application using their Google credentials. It leverages the OAuth 2.0 framework to authenticate Users and obtain the necessary Access Token to access the required information.</p><ul><li><strong>User Accesses the App: </strong>The User opens the Application and attempts to Login.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*4v44o5NjGYbplBQI" /><figcaption>Screen1: User interacts with the app</figcaption></figure><ul><li><strong>User Interacts with “Sign in with Google”: </strong>The User clicks on the “Sign in with Google” button provided by the Application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WoBfQNqbG77vIJuO" /><figcaption>Screen2: Sign in with Google</figcaption></figure><ul><li><strong>User Successfully Authenticates with Google Account: </strong>The User is redirected to Google’s authentication page, where they enter their Google account credentials.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*lNHOE31LcCdNe7vA3pYQ-Q.png" /><figcaption>Screen3: User successfully authenticates with their Google account</figcaption></figure><ul><li><strong>User Gains Access to the Application: </strong>After successful authentication, the User is redirected back to the Application and gains access to its features.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*xWZmIEo_zK33CepbEm-GIw.png" /><figcaption>Screen4: User can access app features</figcaption></figure><p><strong>Steps Involved:</strong></p><p><strong>- Application Registration with Google:</strong> Register the Application with the Google Developers console to obtain the necessary credentials, such as client ID and client secret. This is necessary for the Application to authenticate Users with Google. We must set up a project, configure the OAuth consent screen, define scopes, add fields like “Authorized JavaScript Origins”, “Authorized Redirect URIs “, and generate the required credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0r3M9dh606TXFtmG" /><figcaption>OAuth consent screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/0*usGdvNmlzTJmk6er" /><figcaption>Scopes screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/0*TtFcUEGI2dV1IM22" /><figcaption>Application credentials section</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*5eGEXGOo5LNRT6eE" /><figcaption>Client registration final screen</figcaption></figure><p>- C<strong>ode Integration for Google Sign-In:</strong> The Application’s codebase has to support the OAuth 2.0 authentication flow. This typically involves using Google’s client libraries or SDKs. The required changes will include:<br>- Configuring Google authentication strategy<br>- Handling the redirection<br>- Retrieving User information from the authenticated response<br>- Mapping the information with the User for uniqueness</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pgKMdlxowd8JMtQd" /><figcaption>Using GoogleStrategy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b6yO__6eHM-FmB02" /><figcaption>Path handling and redirection</figcaption></figure><p><strong>- Database Update:</strong> After a User successfully signs in with their Google account, the authentication response includes a unique identifier associated with the User. To maintain a connection between the authenticated User and their data, updating the Application’s DB with this fetched ID is crucial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_PtWkkpS0YwMkapv" /><figcaption>Response after successful authentication</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/0*7ut2mitlB6bGKZsG" /><figcaption>User DB mapping</figcaption></figure><h3>OAuth Extensions</h3><p>Let’s explore some of the common OAuth extensions and how they expand the capabilities of OAuth 2.0</p><h4>PKCE</h4><p>OAuth 2.0 originally focused on web applications — which rely on secure channels to exchange sensitive data between the Application and the Authorization/Resource Server. However, native mobile and desktop applications operate in different environments; where securing client secrets becomes challenging. Proof Key for Code Exchange (PKCE) addresses this challenge by enhancing security for Authorization Code flows, eventually preventing code interception attacks. PKCE ensures that only the intended Client/Application can exchange the Authorization Code for an Access Token.</p><p>PKCE provides an additional layer of security for native apps by ensuring that malicious actors cannot intercept and exchange the Authorization Code for an Access Token. This extension allows native apps to take full advantage of OAuth 2.0’s authorization capabilities while maintaining the utmost security for User interactions. PKCE was initially designed to protect the Authorization Code flow in mobile apps; and is now recommended to be used for single-page apps as well.</p><p>It is essential to note that while PKCE enhances the security of the Authorization Code flow, it doesn’t prevent app impersonation. PKCE solely focuses on ensuring that the Authorization Codes can only be used by the same app that initiated the flow, preventing Authorization Code Injection.</p><p>The PKCE flow introduces two key components:</p><ul><li>Code Verifier</li><li>Code Challenge</li></ul><p><strong>Steps Involved:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*fAtkwBw1Ks-o3_lXeZ5GZQ.png" /></figure><ol><li><strong>User Accesses the Application:</strong> The User attempts to access the Application.</li><li><strong>Application Generates Code Verifier and Code Challenge:</strong> Native app generates a random Code Verifier and then a Code Challenge from the Code Verifier using a cryptographic method (e.g., BASE64-URL-encoded string of the SHA-256 hash). This is used to prove the Application’s authenticity later in the token exchange process.</li><li><strong>Application Initiates Authorization Request:</strong> The Application initiates the OAuth flow, sending the Code Challenge to the Authorization Server (instead of the Client Secret). The Authorization Server stores the Code Challenge temporarily and associates it with the User.</li><li><strong>User Authenticates and Gives Consent:</strong> The User provides their credentials and, if necessary, grants consent for the requested permissions.</li><li><strong>Authorization Server Provides Authorization Code:</strong> The Authorization Server provides an Authorization Code upon successful authentication and consent.</li><li><strong>Application Requests Access Token with Code Verifier:</strong> The Application sends an Access Token request to the Authorization Server. The request includes the original Code Verifier used to generate the Code Challenge.</li><li><strong>Authorization Server Validates Request: </strong>The Authorization Server validates the Code Verifier against the previously submitted Code Challenge.</li><li><strong>Authorization Server Provides Access Token: </strong>If the verification is successful, the Authorization Server provides an Access Token to the Application.</li><li><strong>Application Accesses Protected Resources:</strong> With the Access Token in hand, the Application can make API requests to the Resource Server to access the protected resources on behalf of the User.</li><li><strong>Resource Access Granted:</strong> The Resource Server validates the Access Token. The Resource Server grants access to the requested resources if the Access Token is valid. Users can now fully use the Application as intended.</li></ol><h4>OpenID Connect (OIDC)</h4><p>OpenID Connect (OIDC) is a dedicated identity and authentication layer built on top of the basic OAuth framework. OIDC extends OAuth to provide essential functionality for supporting the authentication use case, which OAuth was not initially designed for.</p><p>Many sites and applications began adapting OAuth as an authentication mechanism using custom workarounds. These custom OAuth-based authentication mechanisms had limitations, like no standardized approach to request user data for authentication purposes, resulting in different implementations across providers. OIDC addresses these challenges by introducing standardized, identity-related features that enable reliable and uniform authentication via OAuth. This standardization streamlines the Application integration process, eliminating the need for separate custom OAuth mechanisms and unique configurations for each provider.</p><p>From the Client Application perspective, OIDC fits neatly into OAuth, with a few distinctions in terminology. OIDC introduces a set of standardized scopes consistent across all providers and adds an extra response type called ID Token (id_token).</p><p><strong>OIDC Roles: </strong>The roles in OIDC are similar to standard OAuth, with slight terminology differences:</p><ul><li><strong>End User:</strong> The User to be authenticated. It is equivalent to OAuth Resource Owner.</li><li><strong>Relying Party (RP):</strong> The Application requesting User authentication. It is equivalent to OAuth Client Application.</li><li><strong>OpenID Provider (OP):</strong> An OAuth service to support authentication requests using OIDC. It is equivalent to OAuth Authorization Server.</li></ul><p><strong>OIDC Scopes: </strong>OIDC uses Claims that contain requested user information in key-value pairs stored in the Resource Server. The RP includes the openid scope in addition to the other standard scopes like profile, email, etc — this grants the RP read access to specific claims about the User (as per the OpenID specification).</p><p><strong>ID Token: </strong>OIDC introduces the id_token response type (which can be combined with other OAuth response types), a JWT signed with the issuer’s private key and can later be verified and parsed by the Client. The ID Token’s payload contains Claims based on the requested scopes and includes information like the token’s lifetime, User identifier, and User’s last authentication by the OAuth service.</p><p><strong>Example Hybrid Flows:</strong></p><ul><li><strong>scope=openidand </strong><strong>response_type=code<br></strong>After exchanging the Authorization Code, we’ll get both ID Token and Access Token back in response. We do not need to worry about JWT validation in this case because we will receive ID Token over a trusted back-channel.</li><li><strong>response_type=code+id_token<br></strong>We’ll get both ID Token and Authorization Code in the redirect response. Since the ID Token is coming via the front channel, it is not trusted. Hence, validating the JWT signature, issuer, issued at, expired at, nonce value, and other claims is critical.</li></ul><p><strong>Steps Involved:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSlUC6uh3710F_bHkqdu8A.png" /></figure><ol><li><strong>User Initiates Sign-In:</strong> The Client Application (aka RP as per the OIDC spec) detects the User’s unauthenticated state and redirects them to OP for authentication.</li><li><strong>Authentication Request:</strong> The authentication request sent to OP typically includes details such as the redirect URI, requested scopes, and response type.</li><li><strong>User Authentication and Consent:</strong> The User is redirected to the authentication endpoint by OP, where they are prompted to enter their credentials and consent to the requested scopes.</li><li><strong>Issuance of ID Token:</strong> Once the End User successfully authenticates and grants consent, the OP issues an ID token. This token contains requested claims about the End User and serves as a verifiable statement for identification.</li><li><strong>Token Validation and User Login:</strong> RP validates the ID token to ensure its authenticity. Upon successful verification, the End User will be authenticated, and throughout the interaction with the RP, the RP and the OP will manage the End User session securely.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2e05773bfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Not To Fail OSCP On Your First Attempt — AD Special]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://anuragmewar.medium.com/how-not-to-fail-oscp-on-your-first-attempt-ad-special-b0819523e3?source=rss-88a7beb8e854------2"><img src="https://cdn-images-1.medium.com/max/600/1*48GeThQ3w_rWGAYSwbeBpw.png" width="600"></a></p><p class="medium-feed-snippet">I have had many people reach out regarding my OSCP experience; so I decided to write this post, without giving away any spoilers, share my&#x2026;</p><p class="medium-feed-link"><a href="https://anuragmewar.medium.com/how-not-to-fail-oscp-on-your-first-attempt-ad-special-b0819523e3?source=rss-88a7beb8e854------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://anuragmewar.medium.com/how-not-to-fail-oscp-on-your-first-attempt-ad-special-b0819523e3?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0819523e3</guid>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Wed, 02 Nov 2022 03:03:25 GMT</pubDate>
            <atom:updated>2022-11-02T15:50:38.219Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Monitor Bastion Hosts on AWS]]></title>
            <link>https://anuragmewar.medium.com/monitor-bastion-hosts-on-aws-a155d13f882a?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/a155d13f882a</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Fri, 12 Feb 2021 12:26:02 GMT</pubDate>
            <atom:updated>2021-02-15T04:13:36.661Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*uVM3NVGwVf1H1bbtC6jerA.png" /></figure><p>Usually, the production environments are placed within a Virtual Private Cloud and made inaccessible directly from the Internet by literally not having any inbound connectivity. A bastion host acts as a jump server and provides access to VPC restricted systems (acting as SSH tunnel) from an external network.</p><p>By design, a bastion host can be a backdoor and a critical point of network security, hence, a bastion host must be running ONLY when needed. If you have already configured bastion host for SSH logging, that’s great!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*PyGF-cy0dFG6oVLm.gif" /><figcaption>Gif via <a href="https://gfycat.com/gifs">gfycat.com</a></figcaption></figure><p>In this article, we will take a deep dive into monitoring the bastion host(s) for <strong>the total running time, and then sending the alerts to the Slack channel.</strong></p><h4><strong>The Solution Architecture</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQa_4idYhP-4e1mSRJgTbQ.png" /><figcaption><strong>Monitoring system for a single bastion host</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EBWCvUvW38AiI7wSvm40cg.png" /><figcaption><strong>Monitoring system for multiple bastion hosts</strong></figcaption></figure><p>To avoid deadlock, race condition, and the other edge-cases, we will programmatically schedule cloudwatch events for each bastion host separately.</p><h4>Implementing the Solution</h4><p>Now that we know the architecture, let’s take a closer look at the nuts and bolts of actually setting up the same on the AWS environment.</p><ul><li><strong>CloudWatch Rule1:</strong></li></ul><p>This rule uses an event pattern where the service name is EC2, and the event type is EC2 Instance State-change Notification. States defined are stopped, running, and the instance-id contains the Instance ID of bastion host(s).<br>When the bastion hosts are in a stopped or running state, this rule triggers Lambda1.</p><p><strong>Event pattern used-</strong></p><pre>{<br>“source”: [</pre><pre>“aws.ec2”</pre><pre>],</pre><pre>“detail-type”: [</pre><pre>“EC2 Instance State-change Notification”</pre><pre>],</pre><pre>“detail”: {</pre><pre>“state”: [</pre><pre>“stopped”,</pre><pre>“running”</pre><pre>],</pre><pre>“instance-id”: [</pre><pre>&lt;Bastion host instance IDs&gt;</pre><pre>]</pre><pre>}</pre><pre>}</pre><ul><li><a href="https://github.com/5H4D0W-R007/Monitor-Bastion-Hosts/blob/main/lambda1.py"><strong>Lambda1</strong></a><strong>:</strong></li></ul><p>This function is triggered when the bastion host(s) is/are in a stopped/running state. The schedule frequency for the instance-specific CloudWatch rule (programmatically created) is calculated based on the state of the instance.</p><p>The instance ID is fetched from the event object to determine which bastion instance triggered this function. Using Boto3 — EC2, Lambda and Event clients are created, and the current state of the bastion host is stored in a variable called stateCurrent.</p><blockquote><strong>The EC2 service stores a LaunchTime value for each instance which can be found by doing a DescribeInstances call. However, if we stop the instance and then restart it, this value is updated with the new launch time.</strong></blockquote><p><strong>If the bastion host is running-<br></strong>The current system time is fetched and assigned to a variable called currentTime. Based on the defined threshold (for example, t+2 days), the schedule frequency is calculated for CloudWatch rule2. The name of the instance-specific CloudWatch rule is kept unique, and using put_rule()<strong>,</strong> the CloudWatch rule is created. Further, Lambda2 is added as a target to the CloudWatch rule2 using put_targets(), and the instance ID is sent as a payload to Lambda2 via CloudWatch rule2. Eventually, a Slack alert is sent using urllib3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_rtn-P7xONhgfu8NTHt_eQ.png" /></figure><p><strong>If the bastion host is in a stopped state-</strong><br>The instance state is sent as a Slack alert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UvxnO_q795UNzPWI5SGxzA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b0752f37bf366783e2dd814f84330bf/href">https://medium.com/media/1b0752f37bf366783e2dd814f84330bf/href</a></iframe><ul><li><strong>CloudWatch Rule2:</strong></li></ul><p>It is a scheduled event rule calculated according to the threshold defined in lambda1. <br>As soon as lambda2 is invoked by cloudwatch rule2, the function will receive the instanceID (via input JSON stored in the event rule) of the bastion host that triggered CloudWatch rule1.</p><p><strong>Each instance has its CloudWatch rule2 with a unique name-</strong>&lt;instanceID&gt;-uniquename</p><p><strong>Input JSON stored in the event rule-</strong>{“instanceIdLambda&lt;number&gt;”:”&lt;instanceID&gt;”}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*zvUb39iBqTQkvYwKuXCrIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*TUFyyORCrb2_84E4Pijwkg.png" /></figure><ul><li><a href="https://github.com/5H4D0W-R007/Monitor-Bastion-Hosts/blob/main/lambda2.py"><strong>Lambda2</strong></a><strong>:</strong></li></ul><p>This function will determine the current state (using the EC2 client created from boto3) of the instance fetched from the event object. Based on the identified state, the total running time (launch time) is calculated. If the running time exceeds the threshold value, a Slack alert is sent.</p><p>The launch time of the instance is determined and stored in a variable called launchTime. The current system time is stored in a variable called currentTime.</p><p><strong>If the bastion host is running-</strong></p><p>The total running time of the instance is calculated by subtracting launchTime from currentTime<strong>. </strong>The result<strong> </strong>of currentTime-launchTime is stored in a variable called differenceTime.</p><p><em>(In case we want to trigger the alert when the total running time &gt; 2 days)</em></p><p>If differenceTimeDays &gt; 1.9 (to cover the case where the rule is triggered a bit early. Take, for example, 1.99998), using urllib3, a Slack alert is sent.</p><p><strong>Make sure all the triggers (instance-specific CloudWatch rule) to Lambda2 function are active.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BE9e4-sdpB5CIcEc2AdaHg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36708987e7d60c9903c6e487d4c5c064/href">https://medium.com/media/36708987e7d60c9903c6e487d4c5c064/href</a></iframe><p><strong>If you would rather want to trigger daily alerts for the total running time of each bastion host:</strong></p><p>We will write another lambda function (invoked daily) which will monitor-</p><ol><li>Total running time (launch time) of each bastion host</li><li>If there’s a change in the number of bastion hosts</li></ol><ul><li><strong>CloudWatch Rule3:</strong></li></ul><p>This scheduled event triggers lambda3 every day at a specified time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FvWPlmYChg4706iwue6NpA.png" /></figure><ul><li><a href="https://github.com/5H4D0W-R007/Monitor-Bastion-Hosts/blob/main/lambda3.py"><strong>Lambda3</strong></a><strong>:</strong></li></ul><p>This function monitors if there is any change in the number of bastion hosts. The integrity violation, along with the total running time (launch time) of each bastion instance is sent as a Slack alert.</p><p>EC2 resource and client are defined using Boto3, and the current state of the instance is determined. The launch time of the instance is stored in a variable called launchTime<strong>, </strong>and the current system time is stored in a variable called currentTime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*62W7qFuAIs0Ru1CHLpuCww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sG20X3JMrF_fQa4NgAqSdw.png" /></figure><p><strong>If the bastion host is running-</strong><br>The total running time of the bastion host is determined using the same methodology as in Lambda2. The number of instances with isBastion : True is compared with the known number of bastion hosts and stored in a counter variable.</p><ul><li><strong>If there is a change in the number of bastion hosts:</strong><br>Along with the total running time of the bastion instances, the integrity violation Slack alert is sent.</li><li><strong>If there is no change in the number of bastion hosts:</strong><br>The total running time of each bastion instance is sent as a Slack alert.</li></ul><p><strong>If the bastion host is not running-</strong><br>The number of instances with isBastion : True is compared with the known number of bastion instances and stored in a counter variable.</p><ul><li><strong>If there is a change in the number of bastion hosts:</strong><br>The integrity violation Slack alert is sent.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a1f59ad43710d3dd631d0f178b01313/href">https://medium.com/media/1a1f59ad43710d3dd631d0f178b01313/href</a></iframe><blockquote>GitHub Repo: <a href="https://github.com/5H4D0W-R007/Monitor-Bastion-Hosts">https://github.com/5H4D0W-R007/Monitor-Bastion-Hosts</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a155d13f882a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting a CTF using Docker]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://anuragmewar.medium.com/hosting-a-ctf-using-docker-248ecf9f904f?source=rss-88a7beb8e854------2"><img src="https://cdn-images-1.medium.com/max/1508/1*JHD67BiLiyQyEQbBQqso5Q.png" width="1508"></a></p><p class="medium-feed-snippet">Ok, so this is my first write-up ever! I am going to cover my approach to hosting a CTF using Docker.</p><p class="medium-feed-link"><a href="https://anuragmewar.medium.com/hosting-a-ctf-using-docker-248ecf9f904f?source=rss-88a7beb8e854------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://anuragmewar.medium.com/hosting-a-ctf-using-docker-248ecf9f904f?source=rss-88a7beb8e854------2</link>
            <guid isPermaLink="false">https://medium.com/p/248ecf9f904f</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-compose]]></category>
            <dc:creator><![CDATA[Anurag Mewar]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 11:39:41 GMT</pubDate>
            <atom:updated>2023-08-03T12:59:42.550Z</atom:updated>
        </item>
    </channel>
</rss>