<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title type="text">Kailash Bohara</title>
<generator uri="https://github.com/jekyll/jekyll">Jekyll</generator>
<link rel="self" type="application/atom+xml" href="https://kailashbohara.com.np/feed.xml" />
<link rel="alternate" type="text/html" href="https://kailashbohara.com.np/" />
<updated>2026-07-26T18:09:16+00:00</updated>
<id>https://kailashbohara.com.np/</id>
<author>
  <name>Kailash Bohara</name>
  <uri>https://kailashbohara.com.np/</uri>
  
</author>


<entry>
  <title type="html"><![CDATA[Container Security Hardening Guide and its Importance]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2026/07/21/container-security-hardening-guide/" />
  <id>https://kailashbohara.com.np/blog/2026/07/21/container-security-hardening-guide/</id>
  <published>2026-07-21T00:00:00+00:00</published>
  <updated>2026-07-21T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;h2 id=&quot;why-container-security-matters&quot;&gt;Why Container Security Matters&lt;/h2&gt;

&lt;p&gt;Containers share a kernel. Unlike virtual machines, they are not hard boundaries they are namespaced processes with optional control group limits and Linux security modules layered on top. When we treat containers like as “VMs,” and think it inherit controls like VMs such as internal traffic is trusted, root inside the container is harmless this does not satisfies in Kubernetes.&lt;/p&gt;

&lt;p&gt;In a monolithic application architecture, compromise might mean one server. But in Kubernetes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;One privileged pod&lt;/strong&gt; can read host filesystems, access cloud metadata APIs, or pivot to the node IAM role.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;One poisoned image&lt;/strong&gt; in CI can deploy to every environment that trusts the pipeline.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;One missing NetworkPolicy&lt;/strong&gt; can leave the entire cluster open to internal reconnaissance between microservices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;compliance-and-customer-trust&quot;&gt;Compliance and Customer Trust&lt;/h3&gt;

&lt;p&gt;Regulators and auditors expect evidence that production workloads are built from verified artifacts, run with least privilege, encrypt sensitive data, and leave an audit trail when configurations change. Frameworks such as SOC 2, ISO 27001, HIPAA, and PCI DSS all map to concrete Kubernetes practices: signed images and SBOMs for supply chain integrity, RBAC and secret management for access control, NetworkPolicies for segmentation, and centralized logging for monitoring and incident response. Below are basic controls that auditors might ask evidence for:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Signature verification logs at deploy time&lt;/li&gt;
  &lt;li&gt;SBOM + vulnerability scan reports per release&lt;/li&gt;
  &lt;li&gt;Least-privilege RBAC and secret handling&lt;/li&gt;
  &lt;li&gt;Use of non-root user and no privileged pods&lt;/li&gt;
  &lt;li&gt;Kubernetes audit logs for who changed cluster resources and when&lt;/li&gt;
  &lt;li&gt;Scan report that align with CIS Benchmarks and Pod Security Standards&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;cost-of-getting-it-wrong&quot;&gt;Cost of Getting It Wrong&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Missing Controls&lt;/th&gt;
      &lt;th&gt;Typical Impact&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Root + privileged pod&lt;/td&gt;
      &lt;td&gt;Node compromise, cluster takeover&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:latest&lt;/code&gt; tag in production&lt;/td&gt;
      &lt;td&gt;Uncontrolled rollbacks, unknown CVE exposure&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Secrets in ConfigMaps&lt;/td&gt;
      &lt;td&gt;Credential theft, data exfiltration&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;No network segmentation&lt;/td&gt;
      &lt;td&gt;Lateral movement after initial foothold&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Weak CI/CD identity&lt;/td&gt;
      &lt;td&gt;Supply chain compromise at scale&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;defense-in-depth-how-the-control-domains-fit-together&quot;&gt;Defense in Depth: How the Control Domains Fit Together&lt;/h2&gt;

&lt;p&gt;The security controls below are not separate items to pick and choose from. They work together like layers of one system.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TB
    subgraph Layer1[&quot;Layer 1: Supply Chain &amp;amp; Deployment&quot;]
        A1[Signed Images]
        A2[SBOM Validation]
        A3[GitOps + Approvals]
        A4[Separate Build/Deploy Identity]
    end

    subgraph Layer2[&quot;Layer 2: Cluster &amp;amp; Infrastructure&quot;]
        B1[API Server Hardening]
        B2[etcd Encryption]
        B3[Node Hardening]
        B4[Admission Controllers]
    end

    subgraph Layer3[&quot;Layer 3: Workload Configuration&quot;]
        C1[Non-Root / PSS Restricted]
        C2[Resource Limits &amp;amp; QoS]
        C3[Network Policies]
        C4[Service Mesh mTLS]
    end

    subgraph Layer4[&quot;Layer 4: Runtime &amp;amp; Detection&quot;]
        D1[Image Scanning]
        D2[Runtime Anomaly Detection]
        D3[Falco Alerts]
        D4[Audit Logging]
    end

    Layer1 --&amp;gt; Layer2 --&amp;gt; Layer3 --&amp;gt; Layer4

    style Layer1 fill:#e8f4fd
    style Layer2 fill:#d4edda
    style Layer3 fill:#fff3cd
    style Layer4 fill:#f8d7da
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;secure-reference-architecture&quot;&gt;Secure Reference Architecture&lt;/h2&gt;

&lt;p&gt;The following diagram illustrates a production-grade secure container platform.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart LR
    Git[Git Repository] --&amp;gt; CI[CI Pipeline&amp;lt;br/&amp;gt;Build · Scan · Sign · SBOM]
    CI --&amp;gt; Reg[(Private Registry)]
    Reg --&amp;gt; CD[GitOps Deploy&amp;lt;br/&amp;gt;+ Prod Approval]
    CD --&amp;gt; K8s[(Kubernetes Cluster)]
    K8s --&amp;gt; Policy[Policy Layer&amp;lt;br/&amp;gt;Admission · PSS · Network]
    K8s --&amp;gt; Observe[Observability&amp;lt;br/&amp;gt;Logs · Metrics · Runtime]
    K8s --&amp;gt; Identity[Identity&amp;lt;br/&amp;gt;Secrets · Service Accounts]
    style CI fill:#e8f4fd
    style CD fill:#d4edda
    style K8s fill:#fff3cd
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Internal cluster traffic is not automatically secure. We should implement Network Policies and service mesh mTLS for identity-aware communication.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TB
    subgraph Ingress[&quot;Ingress Layer&quot;]
        WAF[WAF / API Gateway]
        TLS[TLS Termination]
    end

    subgraph NS_Frontend[&quot;Namespace: frontend&quot;]
        FE[Frontend Pods]
    end

    subgraph NS_API[&quot;Namespace: api&quot;]
        API[API Pods]
    end

    subgraph NS_Data[&quot;Namespace: data&quot;]
        DB[(Database Pods)]
    end

    subgraph Egress[&quot;Egress Control&quot;]
        EGW[Egress Gateway / Firewall]
        Ext[External APIs]
    end

    Internet((Internet)) --&amp;gt; WAF --&amp;gt; TLS --&amp;gt; FE
    FE --&amp;gt;|&quot;NetworkPolicy: allow 443&quot;| API
    API --&amp;gt;|&quot;NetworkPolicy: allow 5432&quot;| DB
    API --&amp;gt;|&quot;Restricted egress&quot;| EGW --&amp;gt; Ext

    FE -.-&amp;gt;|&quot;mTLS via Service Mesh&quot;| API
    API -.-&amp;gt;|&quot;mTLS via Service Mesh&quot;| DB

    style NS_Frontend fill:#e8f4fd
    style NS_API fill:#d4edda
    style NS_Data fill:#fff3cd
&lt;/code&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;why-golden-images-matter&quot;&gt;Why Golden Images Matter&lt;/h2&gt;

&lt;p&gt;A golden image is a pre-approved, minimal base image that every team should builds instead of pulling random public images. Think of it as the standard front door every application must use—same locks, same thickness, same inspection before anyone moves in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why security teams care:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Smaller attack surface&lt;/strong&gt; : A slim base image contains fewer packages, which means fewer known vulnerabilities to patch and fewer places for attackers to hide tools.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Consistent hardening&lt;/strong&gt; : Non-root user, dropped capabilities, and security patches are applied once in the golden image, not reimplemented (or forgotten) by every development team.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Faster, reliable scanning&lt;/strong&gt; : When all apps share a known base, vulnerability scans are repeatable. You scan the golden image and every app built on top of it inherits that baseline.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Audit and compliance&lt;/strong&gt; : Auditors can review one approved image pipeline instead of hundreds of one-off Dockerfiles. You can show exactly what is allowed to run in production.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Supply chain control&lt;/strong&gt; : Only blessed images from your private registry get deployed. Unknown or tampered public images never reach the cluster.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;implementation-roadmap&quot;&gt;Implementation Roadmap&lt;/h2&gt;

&lt;p&gt;Prioritize controls by risk reduction vs effort. The phased approach below mirrors what most security engineering teams deploy successfully.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TB
    subgraph P1[&quot;Phase 1 — Foundation (Weeks 1–4)&quot;]
        direction TB
        P1A[Non-root users and resource limits]
        P1B[Private registry with pinned tags]
        P1C[RBAC review and service accounts]
        P1D[Centralized logging]
    end

    subgraph P2[&quot;Phase 2 — Policy (Weeks 5–10)&quot;]
        direction TB
        P2A[Image scanning in CI]
        P2B[Pod Security Standards]
        P2C[Admission controllers]
        P2D[Default-deny Network Policies]
    end

    subgraph P3[&quot;Phase 3 — Supply Chain (Weeks 11–16)&quot;]
        direction TB
        P3A[Signed images and SBOM]
        P3B[GitOps with production approvals]
        P3C[Separate build and deploy identities]
    end

    subgraph P4[&quot;Phase 4 — Advanced (Ongoing)&quot;]
        direction TB
        P4A[Encrypted service-to-service traffic]
        P4B[Runtime threat detection]
        P4C[Automated benchmark compliance scans]
    end

    P1 --&amp;gt; P2 --&amp;gt; P3 --&amp;gt; P4

    style P1 fill:#e8f4fd
    style P2 fill:#d4edda
    style P3 fill:#fff3cd
    style P4 fill:#f8d7da
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;phase-1--easy-to-implement-weeks-14&quot;&gt;Phase 1 — Easy to implement (Weeks 1–4)&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Enforce non-root, drop capabilities, read-only root FS where feasible&lt;/li&gt;
  &lt;li&gt;Eliminate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:latest&lt;/code&gt;; pin image digests&lt;/li&gt;
  &lt;li&gt;Define CPU/memory limits on all workloads&lt;/li&gt;
  &lt;li&gt;Enable centralized logging and basic monitoring alerts&lt;/li&gt;
  &lt;li&gt;Audit RBAC; remove broad admin access where possible&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;phase-2--policy-enforcement-weeks-510&quot;&gt;Phase 2 — Policy Enforcement (Weeks 5–10)&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Deploy admission policies to block privileged pods and unapproved registries&lt;/li&gt;
  &lt;li&gt;Adopt Pod Security Standards (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;restricted&lt;/code&gt; for new workloads)&lt;/li&gt;
  &lt;li&gt;Implement default-deny NetworkPolicies per namespace&lt;/li&gt;
  &lt;li&gt;Integrate image scanning in CI&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;phase-3--supply-chain-integrity-weeks-1116&quot;&gt;Phase 3 — Supply Chain Integrity (Weeks 11–16)&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Sign images; verify signatures at admission&lt;/li&gt;
  &lt;li&gt;Generate and store SBOMs per release&lt;/li&gt;
  &lt;li&gt;Use GitOps with branch protections and production approval workflows&lt;/li&gt;
  &lt;li&gt;Split CI build identity from CD deploy identity&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;phase-4--runtime--zero-trust-never-ending-process&quot;&gt;Phase 4 — Runtime &amp;amp; Zero Trust (Never ending process)&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Encrypt service-to-service traffic for sensitive tiers&lt;/li&gt;
  &lt;li&gt;Runtime anomaly detection and automated response playbooks&lt;/li&gt;
  &lt;li&gt;Continuous benchmark compliance scanning&lt;/li&gt;
  &lt;li&gt;Secret rotation automation&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;threat-model-before-and-after-hardening&quot;&gt;Threat Model: Before and After Hardening&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart LR
    subgraph Before[&quot;Before Hardening&quot;]
        T1[Attacker] --&amp;gt; I1[Compromised App]
        I1 --&amp;gt; P1[Privileged Pod]
        P1 --&amp;gt; N1[Node + IAM Role]
        N1 --&amp;gt; C1[Cluster Admin / Cloud Account]
    end

    subgraph After[&quot;After Hardening&quot;]
        T2[Attacker] --&amp;gt; I2[Compromised App]
        I2 --&amp;gt;|NetworkPolicy blocks| X1[Blocked Lateral Move]
        I2 --&amp;gt;|Non-root + seccomp| X2[Escalation Failed]
        I2 --&amp;gt;|Runtime alert| SOC[SOC Detects &amp;amp; Isolates]
        I2 --&amp;gt;|Scoped SA only| X3[No Cloud Metadata Access]
    end

    style Before fill:#f8d7da
    style After fill:#d4edda
&lt;/code&gt;&lt;/pre&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Container security is not a single tool. It is architecture, process, and culture expressed through enforceable controls. The checklist your organization is implementing spans runtime isolation, resilient operations, observability, supply chain integrity, identity, network zero trust, runtime detection, governance, and platform hardening. Each domain reinforces the others.&lt;/p&gt;

&lt;p&gt;As a security engineer, my advice is direct: start with what attackers exploit first privileged pods, public images, missing network segmentation, and over-permissioned CI/CD and automate denial of bad configurations at admission time. Scanning and monitoring catch what policy misses.&lt;/p&gt;


    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2026/07/21/container-security-hardening-guide/&quot;&gt;Container Security Hardening Guide and its Importance&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on July 21, 2026.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Hardcoded Credentials in an Android Application Leading to Unauthorized API Access and PII Exposure]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2025/07/07/Hardcoded-Credentials-in-an-Android-Application/" />
  <id>https://kailashbohara.com.np/blog/2025/07/07/Hardcoded-Credentials-in-an-Android-Application/</id>
  <published>2025-07-07T00:00:00+00:00</published>
  <updated>2025-07-07T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;

&lt;p&gt;During a security assessment of an Android application, hardcoded secrets, including the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clientID&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clientSecret&lt;/code&gt;, were discovered embedded directly in the application’s source code. These credentials were trivially accessible to anyone who decompiles or inspects the APK. With these credentials, an attacker could authenticate against the application’s backend APIs and retrieve sensitive data, including customers’ Personally Identifiable Information (PII).&lt;/p&gt;

&lt;h2 id=&quot;impact&quot;&gt;Impact&lt;/h2&gt;

&lt;p&gt;By leveraging the hardcoded credentials, an attacker can:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Authenticate to backend APIs without any user interaction or authorization flow.&lt;/li&gt;
  &lt;li&gt;Extract PII such as names, email addresses, phone numbers, and physical addresses.&lt;/li&gt;
  &lt;li&gt;Enumerate and dump data across multiple API endpoints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A breach of this nature can result in regulatory fines, legal consequences, reputational damage, loss of customer trust, and potential fraud.&lt;/p&gt;

&lt;h2 id=&quot;vulnerable-endpoints&quot;&gt;Vulnerable Endpoints&lt;/h2&gt;

&lt;p&gt;The credentials were found in the following decompiled classes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;com/[redacted]/app/BuildConfig.java&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;com/[redacted]/app/StidClientModule.java&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;steps-to-reproduce&quot;&gt;Steps to Reproduce&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Decompile the APK (e.g., using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jadx&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apktool&lt;/code&gt;). In this case, we used MobSF.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BuildConfig.java&lt;/code&gt; file. Multiple sensitive keys, tokens, and credentials are hardcoded in plaintext.
&lt;img src=&quot;/images/posts/Android%20Hardcoded%20Secrets/hardcoded-secrets-0.png&quot; alt=&quot;Hardcoded secrets in BuildConfig.java&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Following the API documentation, we identified the authentication flow for the backend services.
&lt;img src=&quot;/images/posts/Android%20Hardcoded%20Secrets/hardcoded-secrets-1.png&quot; alt=&quot;API documentation&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Construct a Basic Authorization header from the extracted &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clientID&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clientSecret&lt;/code&gt;.
&lt;img src=&quot;/images/posts/Android%20Hardcoded%20Secrets/hardcoded-secrets-2.png&quot; alt=&quot;Basic Auth token generation&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Exchange the Basic Auth token for an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;access_token&lt;/code&gt; via the token endpoint.
&lt;img src=&quot;/images/posts/Android%20Hardcoded%20Secrets/hardcoded-secrets-3.png&quot; alt=&quot;Access token response&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Using the access token, fetch the existing sites for this particular client.
&lt;img src=&quot;/images/posts/Android%20Hardcoded%20Secrets/hardcoded-secrets-4.png&quot; alt=&quot;Sites enumeration&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Make a GET request to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://[redacted]/api/GetVirtualCardListV2/?siteId=[redacted]&lt;/code&gt;. The response returned thousands of records containing PII (email addresses, phone numbers, and other personal data).
&lt;img src=&quot;/images/posts/Android%20Hardcoded%20Secrets/hardcoded-secrets-5.png&quot; alt=&quot;PII data exposure&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;lessons-learned&quot;&gt;Lessons Learned&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Never hardcode secrets in client-side code.&lt;/li&gt;
  &lt;li&gt;Implement proper OAuth 2.0 flows where tokens are issued server-side and scoped appropriately.&lt;/li&gt;
  &lt;li&gt;Apply rate limiting and anomaly detection on API endpoints to detect bulk data extraction.&lt;/li&gt;
  &lt;li&gt;Conduct regular static analysis scans on mobile builds to catch hardcoded secrets before release.&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2025/07/07/Hardcoded-Credentials-in-an-Android-Application/&quot;&gt;Hardcoded Credentials in an Android Application Leading to Unauthorized API Access and PII Exposure&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on July 07, 2025.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Website Source Code Analysis To AWS Account Takeover]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2024/05/06/website-source-code-analysis-to-aws-account-takeover/" />
  <id>https://kailashbohara.com.np/blog/2024/05/06/website-source-code-analysis-to-aws-account-takeover/</id>
  <updated>2024-05-06T00:00:00-00:00</updated>
  <published>2024-05-06T00:00:00+00:00</published>
  
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;We are going to discuss a vulnerability that I found by checking the source code of a website, which escalated to gaining access to the AWS account of an organization.&lt;/p&gt;

&lt;p&gt;During the security assessment of an organization, I began by browsing their corporate website to understand their business purpose and the solutions they provide. Since the corporate website only had static information and nothing more, I started scanning for subdomains using the &lt;a href=&quot;https://github.com/projectdiscovery/subfinder&quot;&gt;subfinder tool&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/AWS%20takeover//Screenshot_2024-04-30_at_23.25.15.png&quot; alt=&quot;Screenshot 2024-04-30 at 23.25.15.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I found only three subdomains using Subfinder and didn’t bother to look for more because I was convinced with the result. Instead, I started looking into the admin subdomain, &lt;a href=&quot;http://admin.target.com/&quot;&gt;admin.target.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To my surprise, when I visited &lt;a href=&quot;http://admin.target.com/&quot;&gt;admin.target.com&lt;/a&gt;, I got a pop-up message from the Trufflehog browser extension.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/AWS%20takeover/Screenshot_2024-04-30_at_23.34.19.png&quot; alt=&quot;Screenshot 2024-04-30 at 23.34.19.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you don’t know about TruffleHog&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;TruffleHog is a browser extension that helps find and detect API keys, credentials, and other sensitive information that may be accidentally exposed in JavaScript code on websites&lt;/p&gt;

&lt;/blockquote&gt;

&lt;p&gt;The Trufflehog pop-up gave me hope that the AWS Access key and AWS Secret key might exist. To confirm this, I browsed the mentioned JS file, i.e., &lt;a href=&quot;https://admin.example.com/main.js&quot;&gt;https://admin.example.com/main.js&lt;/a&gt;, and searched for the keys. I also used the JavaScript beautifier tool to make the chunked JS code look organized, and the result looked like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/AWS%20takeover/Screenshot_2024-05-01_at_00.27.22.png&quot; alt=&quot;Screenshot 2024-05-01 at 00.27.22.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In the image above, we found the AWS Access Key, Secret Key, Bucket and the upload path as well. Access and secret keys are very sensitive information.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;In AWS Identity and Access Management (IAM), &lt;strong&gt;Access Key&lt;/strong&gt; and &lt;strong&gt;Secret Key&lt;/strong&gt; are credentials used to authenticate and authorize interactions with Amazon Web Services (AWS) APIs and services. Using these keys one can make requests to various AWS services.&lt;/p&gt;

&lt;/blockquote&gt;

&lt;p&gt;Now using the AWS CLI, we can configure the found keys and can request AWS. AWS CLI is a utility tool which allows users to manage AWS services directly from the command line. To do so, we need to &lt;a href=&quot;https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html&quot;&gt;install AWS CLI first&lt;/a&gt;. After the installation of AWS CLI, I configured it using the following command.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;aws configure
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After this, I had to input the found access and secret keys. Once I provided the required information, I attempted to list the available buckets in that particular AWS account using the following command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;aws s3 &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Damn! Both the keys were valid and all the S3 buckets were listed as shown.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/AWS%20takeover/Screenshot_2024-05-01_at_00.49.57.png&quot; alt=&quot;Screenshot 2024-05-01 at 00.49.57.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I have masked the bucket names as they have misconfiguration in them and holds sensitive data. Checking the caller identity using the command It was found that the IAM user was specific for the S3 bucket.&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;aws&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sts&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;caller&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;identity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/AWS%20takeover/Screenshot_2024-05-01_at_00.54.33.png&quot; alt=&quot;Screenshot 2024-05-01 at 00.54.33.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then, I attempted to directly visit the S3 bucket URL, as there might be cases of object listing enabled in public buckets due to poorly configured bucket ACLs. The result was alarming: multiple documents and SQL backup files were there.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/AWS%20takeover/Screenshot_2024-05-01_at_00.58.51.png&quot; alt=&quot;Screenshot 2024-05-01 at 00.58.51.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lessons Learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Avoid hardcoding secret keys or credentials in source code.&lt;/li&gt;
  &lt;li&gt;Regularly rotate AWS access/secret keys for added security.&lt;/li&gt;
  &lt;li&gt;Configure Bucket ACLs properly to prevent unauthorized object listings.&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2024/05/06/website-source-code-analysis-to-aws-account-takeover/&quot;&gt;Website Source Code Analysis To AWS Account Takeover&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on May 06, 2024.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Cloudflare transform rules to get an A+ in the security header.]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2023/08/10/adding-security-headers-using-cloudflare-transform-rules-in-a-static-website/" />
  <id>https://kailashbohara.com.np/blog/2023/08/10/adding-security-headers-using-cloudflare-transform-rules-in-a-static-website/</id>
  <published>2023-08-10T00:00:00+00:00</published>
  <updated>2023-08-10T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;In today’s digital age, security is a vital aspect of any website. One way to improve website security is to add security headers to your website. Security headers are a set of HTTP response headers that inform the browser how to behave when it comes to website security.&lt;/p&gt;

&lt;p&gt;In this blog, we will show you how to add security headers to your static website using Cloudflare transform rules. The transform Rules allow us to manage the URI path, query string, and HTTP headers of requests and responses. By Applying the HTTP response header modification rules we will set all required security headers to get an A+ score. Let’s check our website score before configuring the rules using &lt;a href=&quot;https://securityheaders.com/&quot;&gt;https://securityheaders.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/securityheader/header1.png&quot; alt=&quot;website HTPP headers&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We got an ‘F’ grade in website HTTP headers. 😀 The next approach would be fixing the headers and getting ‘A+’ grade. The main complexity here is the website &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;https://kailashbohara.com.np/&lt;/a&gt;  is hosted using GitHub Pages and we have no control on the server to set HTTP headers as the server-level control is not available in GitHub. The next thing is we are using Jekyll on this website, if this has been made with PHP we can set headers directly in PHP code. Okay! let’s fix this issue using Cloudflare transform rules.&lt;/p&gt;

&lt;p&gt;First, we need to confirm that we have enabled the “orange cloud” so that traffic flows through Cloudflare and we can implement various features on it.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/securityheader/header2.png&quot; alt=&quot;Enable orange cloud in cloudflare&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The next step is to create a list of rules in Cloudflare Transform rules. From your Cloudflare dashboard, select the target website and then go to &lt;em&gt;Rules&amp;gt;Transform Rules&amp;gt;modify Response Header&lt;/em&gt;. Then create a new rule checking All incoming requests and set the static response header as shown below. Here, we have implemented &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X-Frame-Options: SAMEORIGIN&lt;/code&gt;  header for preventing clickjacking attacks.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/securityheader/header3.png&quot; alt=&quot;X-Frame-Options header&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In a similar way, set more security headers as shown below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/securityheader/header4.png&quot; alt=&quot;HTTP headers list&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This  adds seven security headers to our website:&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Security&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Policy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;uri&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;src&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//sets rules for resources that can be loaded on a web page&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;Permissions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Policy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;accelerometer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ambient&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sensor&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;autoplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;battery&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;camera&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;cross&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;isolated&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;capture&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;domain&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;encrypted&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;execution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;not&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;rendered&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;execution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;viewport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;fullscreen&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;geolocation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;gyroscope&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;keyboard&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;magnetometer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;microphone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;midi&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;navigation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;override&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;payment&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;picture&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;picture&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;publickey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;credentials&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;screen&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;wake&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;lock&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sync&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;xhr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;usb&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;web&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;share&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;xr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;spatial&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;tracking&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//provides a mechanism to allow and deny the use of browser features in a document or within any iframe&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;Referrer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Policy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;same&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;origin&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//controls how much referrer information should be included with requests&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;Strict&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Transport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Security&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;31536000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;includeSubDomains&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//informs browsers that the site should only be accessed using HTTPS&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Frame&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;SAMEORIGIN&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//indicate a browser not to render a page in a &amp;lt;frame&amp;gt;, &amp;lt;iframe&amp;gt;, &amp;lt;embed&amp;gt; or &amp;lt;object&amp;gt; tag&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Permitted&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Cross&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Policies&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;none&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//limit which data external resources, such as Adobe Flash and PDF documents, can have access on the domain&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;XSS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Protection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;block&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//stops pages from loading when they detect reflected cross-site scripting (XSS) attacks&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After setting up these headers and turning on the transform rules, let’s check our score on &lt;a href=&quot;https://securityheaders.com/&quot;&gt;https://securityheaders.com/&lt;/a&gt; and we got an A+ grade.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/securityheader/header5.png&quot; alt=&quot;A grade in HTTP header&quot; /&gt;&lt;/p&gt;

&lt;p&gt;That’s it! By following these simple steps, we can add security headers to our static website using Cloudflare transform rules. This will help boost the security of any website (static/dynamic) protecting it from common security threats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt; &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers&quot;&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2023/08/10/adding-security-headers-using-cloudflare-transform-rules-in-a-static-website/&quot;&gt;Cloudflare transform rules to get an A+ in the security header.&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on August 10, 2023.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Comprehensive Blog on the Exploitation and Prevention of AWS Route 53 Vulnerabilities]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2023/04/10/Comprehensive-Blog-on-Exploitation-and-Prevention-of-AWS-Route53-Vulnerabilities/" />
  <id>https://kailashbohara.com.np/blog/2023/04/10/Comprehensive-Blog-on-Exploitation-and-Prevention-of-AWS-Route53-Vulnerabilities/</id>
  <published>2023-04-10T00:00:00+00:00</published>
  <updated>2023-04-10T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;Route53 is a service that holds DNS records for our domain and the hosted zones. The services offered by an organization cannot be listed all in a main domain. Hence, an organization often creates subdomains to host different services.&lt;/p&gt;

&lt;p&gt;For example, if we have &lt;a href=&quot;http://example.com&quot;&gt;example.com&lt;/a&gt; as a domain. Then, we can create a list of the following domains for different purposes.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://support.example.com&quot;&gt;support.example.com&lt;/a&gt; - Customer support service&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blog.example.com&quot;&gt;blog.example.com&lt;/a&gt; - To host an organization blog&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://mail.example.com&quot;&gt;mail.example.com&lt;/a&gt; - To host email service&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://careers.example.com&quot;&gt;careers.example.com&lt;/a&gt; - Job page&lt;/p&gt;

&lt;p&gt;Modern websites often use third-party services in subdomains to provide different services. Third-party services like Zendesk, JIRA, Salesforce, Gitlab, Email services, etc. can be integrated into a subdomain.&lt;/p&gt;

&lt;p&gt;The subdomain takeover vulnerability usually occurs when the service used in our subdomain is discontinued but the DNS records remain in our route 53 records. In this case, an attacker can re-register for the service and the DNS records are already in place. This makes the service alive in the targeted subdomain and the control of the subdomain is transferred to an attacker. An attacker can host any malicious or false content after the successful subdomain takeover.&lt;/p&gt;

&lt;p&gt;To demonstrate the subdomain takeover in Route 53 We will create a static website in the S3 bucket and then we’ll point that S3 bucket in Route 53.&lt;/p&gt;

&lt;p&gt;Later, we’ll delete the bucket but we will not delete the Route 53 record keeping this vulnerable to an attacker. Then, we will take over the subdomain by creating the deleted bucket in our AWS account.&lt;/p&gt;

&lt;h1 id=&quot;part--1-creating-a-static-website-in-the-s3-bucket&quot;&gt;Part -1: Creating a Static website in the S3 bucket.&lt;/h1&gt;

&lt;p&gt;In this part, we will create an s3 bucket upload an HTML file to it and configure it for static website hosting.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Go S3 bucket and create a new bucket with the blog.enhancingsecurity.com&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%201.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Make sure you check “ACLs enabled” in object ownership and uncheck “Block all public access”, as this is a website and its file should be accessible to the public.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%202.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now, we will write a simple HTML file and upload it into the bucket.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%203.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;After successful upload, Go to bucket properties and scroll to the bottom of the page. There you can see the feature of enabling “Static website hosting”. Make sure you enable this. While enabling this we need to specify the default page for our website. We will input “index.html” as the default page for our blog website.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%204.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Once the static website is created we can see our website address as shown below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%205.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now, we’ll make the bucket objects public by selecting all the objects of the bucket and going to the Actions menu and selecting “Make public using ACL”&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%206.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Once we make the objects public the website should render as shown below by visiting the bucket website endpoint.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%207.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;part--2-pointing-s3-static-website-to-a-subdomain&quot;&gt;Part -2: Pointing S3 static website to a subdomain&lt;/h1&gt;

&lt;p&gt;We have successfully created a static website in the s3 bucket. The bucket website endpoint is &lt;a href=&quot;http://blog.enhancingsecurity.com.s3-website-ap-southeast-1.amazonaws.com/&quot;&gt;http://blog.enhancingsecurity.com.s3-website-ap-southeast-1.amazonaws.com&lt;/a&gt; and now we will point this address to blog.enhancingsecurity.com so that this bucket address resolves to our subdomain.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%208.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Go to Route 53 and select a hosted zone for &lt;a href=&quot;http://enhancingsecurity.com&quot;&gt;enhancingsecurity.com&lt;/a&gt;. We can see the DNS records below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%209.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now we will create another subdomain with the name blog. The final subdomain will be &lt;a href=&quot;http://blog.enhancingsecurity.com&quot;&gt;blog.enhancingsecurity.com&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;While creating a subdomain, select record type as “A record”, enable Alias and select Route traffic to Alias to S3 Website endpoint. And then select the bucket region as Singapore (we created a bucket in this region in Step 1). You’ll option to select the s3 bucket endpoint as shown below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2010.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now we can see &lt;a href=&quot;http://blog.enhancingsecurity.com/&quot;&gt;blog.enhancingsecurity.com&lt;/a&gt; pointed to &lt;a href=&quot;http://s3-website-ap-southeast-1.amazonaws.com/&quot;&gt;s3-website-ap-southeast-1.amazonaws.com&lt;/a&gt;. which resolves to our static s3 website.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2011.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;As we can see our S3 static website content in the blog.enhancingsecurity.com&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2012.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;part--3-deleting-the-s3-bucket&quot;&gt;Part -3: Deleting the S3 Bucket&lt;/h2&gt;

&lt;p&gt;In this section now we will delete the S3 bucket where we have hosted content for our blog. To do this simply go to Amazon S3 and delete the bucket content and then delete the bucket.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2013.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now try to resolve the subdomain &lt;a href=&quot;http://blog.enhancingsecurity.com/&quot;&gt;http://blog.enhancingsecurity.com/&lt;/a&gt; and we can see the following error message.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2014.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The error message indicates that the bucket does not exist. This means that anyone can register the bucket with the same name and host the desired content. Now, we will do the same in part -4.&lt;/p&gt;

&lt;h2 id=&quot;part--4-taking-over-the-subdomain&quot;&gt;Part -4: Taking over the Subdomain&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;Now we will log into another AWS account and create a s3 bucket with the same name  &lt;a href=&quot;http://blog.enhancingsecurity.com&quot;&gt;blog.enhancingsecurity.com&lt;/a&gt;  in the Asia Pacific (Singapore) ap-southeast-1 region.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2015.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Like before we will upload a file and make the bucket publicly accessible and also make the object public access using ACL. Then we will upload an HTML file with our takeover message as shown below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2016.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Like before we are enabling the static website hosting feature and specifying the index.html file as an index document which has a subdomain takeover message.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2017.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now if we visit the &lt;a href=&quot;http://blog.enhancingsecurity.com&quot;&gt;blog.enhancingsecurity.com&lt;/a&gt; we can see that we can host our content on that website by creating a s3 bucket in our AWS account.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2018.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is how we can take over the subdomain of a website if it has existing DNS records and is eligible for takeover. You refer to this GitHub repo to check which services are vulnerable to takeover and which are not. &lt;a href=&quot;https://github.com/EdOverflow/can-i-take-over-xyz&quot;&gt;Can I Take Over XYZ&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;elastic-beanstalk&quot;&gt;Elastic Beanstalk:&lt;/h3&gt;

&lt;p&gt;AWS Elastic Beanstalk is a service that makes it easy to deploy and scale web applications and services. If an Elastic Beanstalk environment is misconfigured or becomes unused, an attacker could potentially register the same subdomain that was previously used by the Elastic Beanstalk application. This could allow the attacker to take control of that subdomain and potentially gain access to sensitive information or resources associated with the original application.&lt;/p&gt;

&lt;p&gt;Identifying vulnerable Elastic Beanstalk domains is quite easy. We only need to check that we get an NXDOMAIN response to our DNS query and that the pointed domain has the form &lt;name&gt;.&lt;aws-region&gt;.elasticbeanstalk.com&lt;/aws-region&gt;&lt;/name&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Go to the Elastic Beanstalk service in AWS and create a new app with the following configuration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2019.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;On the same page, we will select a basic app code to make it run. For now, we are selecting a NodeJs web application.&lt;/li&gt;
  &lt;li&gt;After completing all the steps we will see our application is launching with a unique AWS Elastic Beanstalk domain as shown below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2020.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Opening the Elastic Beanstalk domain we can see NodeJs default page below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2021.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now we’ll point this elastic beanstalk app to route53 DNS record to point it to &lt;a href=&quot;http://myapp.enhancingsecurity.com&quot;&gt;myapp.enhancingsecurity.com&lt;/a&gt;. We will create an “A record” for our subdomain that points to our created beanstalk environment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2022.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;After the successful point, we can see our default NodeJS app is loaded in &lt;a href=&quot;http://myapp.enhancingsecurity.com&quot;&gt;myapp.enhancingsecurity.com&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2023.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now we’ll delete the Beanstalk app but not the Route 53 record and check the ns record using the command&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;nx&quot;&gt;nslookup&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;myapp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;enhancingsecurity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2024.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If we see the message “** server can’t find &lt;a href=&quot;http://myapp.enhancingsecurity.com/&quot;&gt;myapp.enhancingsecurity.com&lt;/a&gt;: NXDOMAIN,” this confirms that our subdomain is vulnerable to takeover.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2025.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Now, we will create the elastic beanstalk app with the same name in the same region in another AWS account. This will point our beanstalk app to the subdomain &lt;a href=&quot;http://myapp.enhancingsecurity.com/&quot;&gt;myapp.enhancingsecurity.com&lt;/a&gt;. This time, we are selecting a web app as PHP, and we get the beanstalk domain response as below.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2026.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Checking the subdomain &lt;a href=&quot;http://myapp.enhancingsecurity.com/&quot;&gt;http://myapp.enhancingsecurity.com/&lt;/a&gt; we get our PHP application is running.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route53/Untitled%2027.png&quot; alt=&quot;Untitled&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;aws-route53-dns-security-practices&quot;&gt;&lt;a href=&quot;&quot;&gt;&lt;strong&gt;AWS Route53 DNS Security Practices&lt;/strong&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Periodically audit and clean up outdated or unused DNS records to reduce the attack surface.&lt;/li&gt;
  &lt;li&gt;Enable Domain Privacy Protection in AWS Route 53 to protect domain owners’ personal information.&lt;/li&gt;
  &lt;li&gt;Enable Auto-Renewal for a Domain. This prevents service disruptions or loss of ownership.&lt;/li&gt;
  &lt;li&gt;Restrict access to Route 53 resources with finely tuned Identity and Access Management (IAM) policies, granting the least privilege permissions only to users and applications that need them.&lt;/li&gt;
  &lt;li&gt;For private hosted zones, limit access to Route 53 resolvers to only trusted VPCs to protect internal DNS data.&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2023/04/10/Comprehensive-Blog-on-Exploitation-and-Prevention-of-AWS-Route53-Vulnerabilities/&quot;&gt;Comprehensive Blog on the Exploitation and Prevention of AWS Route 53 Vulnerabilities&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on April 10, 2023.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Exploiting thousands of Domains for XSS]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2023/01/02/exploiting-thousands-of-domains-for-XSS/" />
  <id>https://kailashbohara.com.np/blog/2023/01/02/exploiting-thousands-of-domains-for-XSS/</id>
  <published>2023-01-02T00:00:00+00:00</published>
  <updated>2023-01-02T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;This blog post is about Cross-Site Scripting (XSS) vulnerability found on the secure page of GoDaddy.&lt;/p&gt;

&lt;p&gt;While pen testing in wide scope for a client I found a subdomain as files.example.com. Opening in browser results as shown below&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/godaddy/1.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After that, I ran a Burp Suite auto scan over it, and the reflector (a Burps Suite extension) showed that some inputs got reflected in the response.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/godaddy/2.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now it’s time to find a vulnerability for script injection. After analyzing the suspicious parameter, I found a possible way for the execution of JavaScript code and was finally able to execute it as shown below. The vulnerable URL looks like: &lt;em&gt;http://files.example.com/index.php/”onmouseleave=”alert(‘XSS’)”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/godaddy/3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;But wait, what is the use of this webpage, and who added this subdomain? Checking the CNAME of this subdomain, I found that it belongs to Godaddy.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/godaddy/4.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As a service provider, Godaddy must have thousands of clients using this service (probably the file-sharing feature), and all of them are vulnerable to the Cross-Site Scripting (XSS) vulnerability. To verify this, I thought of using simple Google Dork to find similar web pages.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/godaddy/5.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;However, this is not the appropriate way, hence I discussed with @smaranchand possible ways of gathering all the subdomains on the internet that are using &lt;a href=&quot;http://files.secureserver.net/&quot;&gt;files.secureserver.net&lt;/a&gt;
 as CNAME in their DNS records. He came up with the idea of using &lt;a href=&quot;https://explore.silentpush.com/explore-result?name=files.secureserver.net&amp;amp;queryType=answer&amp;amp;type=CNAME&quot;&gt;Silent Push&lt;/a&gt;. We used reverse CNAME lookup to find affected domains for the XSS vulnerability and found that around 13,092 domains were vulnerable. This is a very large number of vulnerable systems that we can impact with a vulnerability.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/godaddy/6.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After confirming the vulnerability on a few subdomains, I decided to notify GoDaddy security and email them a detailed proof of concept using their email security@godaddy.com. However, they didn’t respond until. To my surprise, the vulnerability has been patched by them. After a few searches, I also came to know that the same vulnerability had previously been reported by &lt;a href=&quot;https://medium.com/@turbobarsuchiha?source=post_page-----5828c3e2040c--------------------------------&quot;&gt;turbobarsuchiha&lt;/a&gt;. She also did not receive any reasonable response from GoDaddy and decided to post on her blog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson Learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Always monitor third-party DNS entries and hosted applications for possible threats and vulnerabilities.&lt;/li&gt;
  &lt;li&gt;Never exclude static pages for security testing.&lt;/li&gt;
  &lt;li&gt;Examine each issue generated by Burp Suite manually.&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2023/01/02/exploiting-thousands-of-domains-for-XSS/&quot;&gt;Exploiting thousands of Domains for XSS&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on January 02, 2023.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[How I bypassed PHP functions to read sensitive files on server]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2022/02/04/bypassing-PHP-functions-to-read-system-file-copy/" />
  <id>https://kailashbohara.com.np/blog/2022/02/04/bypassing-PHP-functions-to-read-system-file-copy/</id>
  <published>2022-02-04T00:00:00+00:00</published>
  <updated>2022-02-04T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;During the penetration testing of a target, the &lt;a href=&quot;https://github.com/projectdiscovery/nuclei&quot;&gt;nuclei&lt;/a&gt; results show that the website of an organization is vulnerable to code execution vulnerability i.e &lt;a href=&quot;https://blog.ovhcloud.com/cve-2017-9841-what-is-it-and-how-do-we-protect-our-customers/&quot;&gt;CVE-2017-9841&lt;/a&gt;. The CVE-2017-9841 vulnerability lets a user run PHP code on vulnerable websites remotely, by exploiting a breach in PHPUnit lets us run desirable PHP codes and read sensitive files.&lt;/p&gt;

&lt;p&gt;After checking all the things, I verified the existence of vulnerability making the proper request in Burp suite, and confirmed by running of the PHP function,  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getcwd()&lt;/code&gt; that returns the current working directory.&lt;img src=&quot;/images/posts/rce1.png&quot; alt=&quot;php getcwd() function&quot; /&gt;
Now there won’t be any problem running system commands by using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell_exec()&lt;/code&gt; function in PHP. This function executes user-supplied commands and returns output as a string. I did this by simply listing all the home directories/files of the current user.&lt;img src=&quot;/images/posts/rce2.png&quot; alt=&quot;&quot; /&gt; Finally, reading the config file was just easy as reading this post. &lt;img src=&quot;/images/posts/rce3.png&quot; alt=&quot;&quot; /&gt; I stopped over here and thought of reporting this issue to the organization but because of the tight schedule of my daily life I was unable to report the issue for 4-5 days. After a few days I thought of reporting the issue but wanted to confirm whether the vulnerability still exists or not. &lt;strong&gt;But to my surprise 😕 It wasn’t working as before&lt;/strong&gt; 😂. &lt;img src=&quot;/images/posts/rce4.png&quot; alt=&quot;&quot; /&gt;
As per my guess within 4-5 days, the administrator might have checked the logs or might be aware of the exploit that I tried and made fixation to it. Hence, the execution of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell_exec()&lt;/code&gt; function was forbidden. However, few other functions could still be executed except shell_exec(). From the image below I confirmed that the execution was forbidden by applying some filter in the phpinfo file.&lt;img src=&quot;/images/posts/rce5.png&quot; alt=&quot;&quot; /&gt; Along with shell_exec(), other functions like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show_source()&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;system()&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shell_exec()&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exec()&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;popen()&lt;/code&gt; and  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;proc_open()&lt;/code&gt; which can be used to read/write files were also disabled.
After this I started looking for other possible ways to read the files again, and found we can use the &lt;a href=&quot;https://www.php.net/manual/en/function.glob.php&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;glob()&lt;/code&gt;&lt;/a&gt; method to return an array of filenames and directories. I used following snippet of code locally and confirmed it returns the array of files and directories.&lt;/p&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;print_r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;glob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Eventually, I was able to  list the files again as shown below, and now all that’s left is to find a way to read those listed files.&lt;img src=&quot;/images/posts/rce6.png&quot; alt=&quot;&quot; /&gt;  At the end, I figured out that I had to combine multiple functions together to read files.&lt;/p&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;../../../../../../../public_html/application/config/database.php&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;explode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;,&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;file_get_contents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;print_r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;In the above code,&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;$a variable is used to set target file which we are going to read. The target file was found using &lt;em&gt;print_r(glob())&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;In the $b variable, we used explode function to return array of strings. &lt;em&gt;file_get_contents()&lt;/em&gt; reads contents of database.php from public_html/application/config/database.php and contents array is returned.&lt;/li&gt;
  &lt;li&gt;Finally, printed contents of $b variable using &lt;em&gt;print_r()&lt;/em&gt; or &lt;em&gt;var_dump()&lt;/em&gt; can also be used. 
&lt;img src=&quot;/images/posts/rce7.png&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2022/02/04/bypassing-PHP-functions-to-read-system-file-copy/&quot;&gt;How I bypassed PHP functions to read sensitive files on server&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on February 04, 2022.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[MSSQL Injection In JSON Request]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2021/05/16/MSSQL-Injection-in-JSON-request/" />
  <id>https://kailashbohara.com.np/blog/2021/05/16/MSSQL-Injection-in-JSON-request/</id>
  <published>2021-05-16T00:00:00+00:00</published>
  <updated>2021-05-16T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;&lt;a href=&quot;https://portswigger.net/web-security/sql-injection&quot;&gt;SQL injection&lt;/a&gt; is a web security vulnerability that allows an attacker to interfere with the queries that an application makes to its database. It generally allows an attacker to view data that they are not normally able to retrieve. The impact of the SQL Injection can be extracting data from the database, dropping data, gaining OS or SQL shell access etc.&lt;/p&gt;

&lt;p&gt;As it was private scope, I do not want to disclose the application name. So, I was testing the android application of it. I had to bypass &lt;a href=&quot;https://developer.android.com/training/articles/security-ssl&quot;&gt;SSL pinning&lt;/a&gt; to intercept the application requests. Finally, I was able to do it. The first page was the registration page while opening an app, I filled in all the necessary details. An OTP code was sent to our provided phone number. I used a random six-digit code and intercepted the OTP validation request as shown below.
&lt;img src=&quot;/images/posts/app_registration.png&quot; alt=&quot;Registration request&quot; /&gt;
Then I sent the above request to Repeater tab in Burp suite and added a single quote on &lt;em&gt;DeviceId&lt;/em&gt; parameter. Modified requests look like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;DeviceId&quot;:&quot;lol&apos;&quot;&lt;/code&gt;
&lt;img src=&quot;/images/posts/app_registration_sqli_req.png&quot; alt=&quot;SQL Injection Request&quot; /&gt;
And the response was like: 
&lt;img src=&quot;/images/posts/app_registration_sqli_resp.png&quot; alt=&quot;SQL Injection Response&quot; /&gt;
This confirms the existence of the vulnerability. To be assured I used the time delay command for few databases as
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SLEEP(10)&lt;/code&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WAITFOR DELAY &apos;0:0:10&apos;&lt;/code&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SELECT pg_sleep(10)&lt;/code&gt; and second one worked as shown below.  &lt;img src=&quot;/images/posts/app_registration_sqli_sleep.png&quot; alt=&quot;SQL Injection Requets&quot; /&gt; &lt;br /&gt;
Then in the response time, we can see 10ms delays. It confirms MSSQL Injection.
&lt;img src=&quot;/images/posts/app_registration_sqli_sleepres.png&quot; alt=&quot;SQL Injection Response&quot; /&gt;
To make proof of concept I decided to create a database object using the query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;CREATE TABLE kailash (line varchar(8000));--&apos;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/app_registration_sqli_tblc.png&quot; alt=&quot;SQL Injection Response&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After discussion with the development team, it was confirmed that the above query executed successfully. &lt;br /&gt;
&lt;img src=&quot;/images/posts/app_registration_sqli_tbl.jpg&quot; alt=&quot;SQL Injection Response&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt;: &lt;em&gt;I used different devices during the assessment so you may find difference in parameter values in used screenshots.&lt;/em&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2021/05/16/MSSQL-Injection-in-JSON-request/&quot;&gt;MSSQL Injection In JSON Request&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on May 16, 2021.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Blind XSS on Google Internal System ]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2021/05/13/Google-blind-XSS/" />
  <id>https://kailashbohara.com.np/blog/2021/05/13/Google-blind-XSS/</id>
  <published>2021-05-13T00:00:00+00:00</published>
  <updated>2021-05-13T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;&lt;a href=&quot;https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/blind-cross-site-scripting/&quot;&gt;Blind cross-site scripting&lt;/a&gt; (XSS) refers to a type of code injection where an attacker inserts XSS payload in user input fields and they are going to be stored somewhere and executes in an application that is not in control of an attacker.&lt;/p&gt;

&lt;p&gt;I ended up finding blind XSS in one of the Google’s internal system (GUTS ticketing system). I used blind XSS payload from &lt;a href=&quot;https://xsshunter.com&quot;&gt;xsshunter&lt;/a&gt; and filled up randomly input fields on the form from Google supplier portal. The forms from the supplier portal must be tracked from GUTS, that’s what I assume and my payload gets executed.&lt;/p&gt;

&lt;h4 id=&quot;what-happened-&quot;&gt;What happened ?&lt;/h4&gt;

&lt;p&gt;I get a response in my xsshunter after a very long time and at the moment I was unknown which parameter I tested for.&lt;img src=&quot;/images/posts/google_reply-1.png&quot; alt=&quot;Google reply&quot; /&gt; I tried to read the &lt;a href=&quot;https://www.w3schools.com/js/js_htmldom.asp&quot;&gt;DOM&lt;/a&gt; so that we may know the possible parameter. Unfortunately, XSS hunter keeps loading and the browser gets
frozen. Only Referer and Cookies are known. I passed the information that I have to the Google team and they finally managed to know the actual cause and rewards me. &lt;img src=&quot;/images/posts/google_reward_xss.png&quot; alt=&quot;Reward message&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I requested to disclose a vulnerable endpoint as seen above but ended up with the following message.&lt;img src=&quot;/images/posts/google_final_reply.png&quot; alt=&quot;Reply&quot; /&gt; As part of Google’s Vulnerability Reward Program, the panel has decided to issue a reward of $5000 for this issue as it affects the sensitive application.&lt;/p&gt;

&lt;h4 id=&quot;giveaway-&quot;&gt;Giveaway ?&lt;/h4&gt;
&lt;p&gt;Always take a log where we tested for XSS. We don’t know when our luck hits in bug bounty.&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2021/05/13/Google-blind-XSS/&quot;&gt;Blind XSS on Google Internal System &lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on May 13, 2021.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[GraphQL IDOR in Facebook streamer dashboard.]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2020/11/18/GraphQL-IDOR-in-Facebook-streamer-dashboard/" />
  <id>https://kailashbohara.com.np/blog/2020/11/18/GraphQL-IDOR-in-Facebook-streamer-dashboard/</id>
  <published>2020-11-18T00:00:00+00:00</published>
  <updated>2020-11-18T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;h4 id=&quot;description&quot;&gt;Description:&lt;/h4&gt;
&lt;p&gt;While viewing our stream dashboard data from creator studio, there is an endpoint from where we can see our dashboard status. There is parameter called &lt;em&gt;profile_id&lt;/em&gt; in GraphQl request which can be misused to access data of other pages by using facebook page_id.&lt;/p&gt;

&lt;h4 id=&quot;steps-to-reproduce&quot;&gt;Steps to Reproduce:&lt;/h4&gt;
&lt;ol&gt;
  &lt;li&gt;Start burpsuite and intercept the request.&lt;/li&gt;
  &lt;li&gt;Go to https://www.facebook.com/gaming/streamer and you will be redirected to creator studio.&lt;/li&gt;
  &lt;li&gt;We will forward all the intercepted request since it’s difficult to spot the correct request which has vulnerable parameters in multiple requests.&lt;/li&gt;
  &lt;li&gt;Meanwhile we will use find feature in burpsuite. we’ll search for &lt;em&gt;“GamesVideoStreamerDashboardProfileQuery”.&lt;/em&gt;
&lt;img src=&quot;/images/posts/graphql-request.png&quot; alt=&quot;graphql-request&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;Once our search query matches we will forward that particular request to repeator and replace &lt;em&gt;profileID&lt;/em&gt; with desired game steaming pageID to see their stream stats. The response of the above request looks like as shown below.
&lt;img src=&quot;/images/posts/graphql-response.png&quot; alt=&quot;graphql-response&quot; /&gt;
According to facebook only highlighted information i.e. &lt;em&gt;“l30_live_earnings”&lt;/em&gt; and &lt;em&gt;“supporter_count”&lt;/em&gt; are sensitive which should not be disclosed to a user which does not have any role in the page.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;conclusion&quot;&gt;Conclusion:&lt;/h4&gt;
&lt;p&gt;After reviewing this issue, Facebook decided to award a bounty of $2000 and they fixed the issue by not displaying those information in the response to a users which does not have any role in page.
&lt;img src=&quot;/images/posts/facebook-reply.png&quot; alt=&quot;facebook-reply&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2020/11/18/GraphQL-IDOR-in-Facebook-streamer-dashboard/&quot;&gt;GraphQL IDOR in Facebook streamer dashboard.&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on November 18, 2020.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[Stored Cross Site Scripting on Mdaemon Webmail (20.0.0)]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2020/07/15/mdaemon-stored-xss/" />
  <id>https://kailashbohara.com.np/blog/2020/07/15/mdaemon-stored-xss/</id>
  <published>2020-07-15T00:00:00+00:00</published>
  <updated>2020-07-15T00:00:00+00:00</updated>
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p&gt;Two different cross site scripting vulnerabilities were found on version below 20.0.1 and reported to Mdaemon team. As per the resposne from their side both issues were addressed on &lt;a href=&quot;http://files.altn.com/MDaemon/Release/relnotes_en.html&quot;&gt;latest version 20.0.1 released&lt;/a&gt; on 18th August 2020.&lt;/p&gt;

&lt;h4 id=&quot;case-one&quot;&gt;Case One:&lt;/h4&gt;

&lt;p&gt;E-mail attachment field is vulnerable to XSS. A attachment with XSS payload as a file name can be uploaded to trigger execution of code. To do that follow steps below:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Rename a file and set it’s name as &lt;code&gt;&amp;lt;img src=x onerror=alert(1)&amp;gt;.jpg &lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Go to New mail, select recipient and the select attachment. Code gets executed as right after upload so it becomes self XSS.
 &lt;img src=&quot;/images/posts/mdaemon-xss-popup.png&quot; alt=&quot;XSS Popup1&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;Let’s send the mail to recipient and open from his/her side. Opening just a mail doesn’t executes the code but when the victim clicks on forward button, XSS pop-up is shown.&lt;br /&gt;
 &lt;img src=&quot;/images/posts/mdaemon-xss-popup-2.png&quot; alt=&quot;XSS Popup 2&quot; /&gt;
 Like this a stored self XSS can also becomes perfect XSS for victim users.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;case-two&quot;&gt;Case Two:&lt;/h4&gt;

&lt;p&gt;So the next vulnerable endpoint is Distribution list. A distribution list holds name and email address of persons. We can also refer it as a address book. Following steps can be followed to execute the vulnerability.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Go to contact section and distribution list menu. Create a new distribution list.&lt;/li&gt;
  &lt;li&gt;Contact name field was vulnerable to XSS. Use the payload &lt;code&gt;&amp;lt;img src=x onerror=alert(1)&amp;gt;&lt;/code&gt; 
&lt;img src=&quot;/images/posts/mdaemon-xss-distribution1.png&quot; alt=&quot;Mdaemon XSS&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;We can see execution code and after saving it, each time we visits the distribution list section the XSS pop-up is seen.
&lt;img src=&quot;/images/posts/mdaemon-xss-distribution2.png&quot; alt=&quot;Mdaemon XSS&quot; /&gt;&lt;/li&gt;
&lt;/ol&gt;

    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2020/07/15/mdaemon-stored-xss/&quot;&gt;Stored Cross Site Scripting on Mdaemon Webmail (20.0.0)&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on July 15, 2020.&lt;/p&gt;
  </content>
</entry>


<entry>
  <title type="html"><![CDATA[CVE-2020-10596 in OpenCart]]></title>
  <link rel="alternate" type="text/html" href="https://kailashbohara.com.np/blog/2020/05/29/CVE-2020-10596/" />
  <id>https://kailashbohara.com.np/blog/2020/05/29/CVE-2020-10596/</id>
  <updated>2020-05-29T00:00:00-00:00</updated>
  <published>2020-05-29T00:00:00+00:00</published>
  
  <author>
    <name>Kailash Bohara</name>
    <uri>https://kailashbohara.com.np/</uri>
    
  </author>
  <content type="html">
    &lt;p style=&quot;text-align: justify;&quot;&gt; Cross-site scripting attacks (XSS), are a type of attack in which malicious scripts are injected into websites and web applications and run on an end user’s platform. Vulnerable endpoints are found and JS code is injected to execute it for malicious purposes. Such endpoints can be search fields, profile information fields, file upload functions and many more. &lt;/p&gt;

&lt;p&gt;An authenticated attack refers to the conditions where an attacker must be logged to exploit the vulnerability. In &lt;a href=&quot;https://www.opencart.com&quot;&gt;OpenCart&lt;/a&gt; 3.0.3.2 it is possible to execute cross site scripting attack since the profile image upload feature in admin panel is not escaping user inputs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To execute follow the steps below.&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Login to the admin panel, navigate to system &amp;gt; users &amp;gt; edit an existing user.&lt;/li&gt;
  &lt;li&gt;Go to the Image change section and select a file with the XSS payload as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;&amp;gt;&amp;lt;svg onload=alert(&quot;XSS&quot;)&amp;gt;&lt;/code&gt; and save it.&lt;/li&gt;
  &lt;li&gt;Thats it.
 &lt;img src=&quot;/images/posts/xss-popup.png&quot; alt=&quot;XSS Popup&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What’s the solution ???&lt;/strong&gt;&lt;/p&gt;

&lt;p style=&quot;text-align: justify;&quot;&gt; The Same payload gets executed for the directory name too. So, I suggested a regex which replaces special characters in filename/directory names with whitespaces and removes white spaces too. &lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Sanitize the filename&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$filename&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;html_entity_decode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;name&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENT_QUOTES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;UTF-8&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//Using regex to filter filename&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;preg_replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;/[^A-Za-z0-9\-\.]/&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Validate the filename length&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;utf8_strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;utf8_strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;error&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;error_filename&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GO_Example_Model_Thing&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GO_Base_Db_ActiveRecord&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;mf&quot;&gt;...&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Outcome:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/xss-filtered.png&quot; alt=&quot;XSS Filter&quot; /&gt;&lt;/p&gt;

&lt;p&gt;But this won’t work if the file containing the payload is uploaded using the FTP service. So one of the solution on issue I have opened on GitHub was &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;preg_replace(&apos;/[^a-zA-Z0-9\_\.\?]/&apos;, &apos;&apos;, basename(html_entity_decode($this-&amp;gt;request-&amp;gt;post[&apos;x&apos;], ENT_QUOTES, &apos;UTF-8&apos;)));&lt;/code&gt; by &lt;strong&gt;&lt;em&gt;straightlight&lt;/em&gt;&lt;/strong&gt;. Let’s see how they add a fix in the main code of the opencart in the next release.&lt;/p&gt;


    &lt;p&gt;&lt;a href=&quot;https://kailashbohara.com.np/blog/2020/05/29/CVE-2020-10596/&quot;&gt;CVE-2020-10596 in OpenCart&lt;/a&gt; was originally published by Kailash Bohara at &lt;a href=&quot;https://kailashbohara.com.np/&quot;&gt;Kailash Bohara&lt;/a&gt; on May 29, 2020.&lt;/p&gt;
  </content>
</entry>

</feed>
