mcpbeat

Strix•不安全文件上传

asdfgh1445/strix•不安全文件上传

Strix 文件上传安全测试手册,覆盖扩展名绕过、Content-Type 操控与路径穿越;触发名:strix-insecure-file-uploads

2k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
715
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/asdfgh1445/ctf-super-hub --skill Strix•不安全文件上传

The instruction itself

36 sections, as written by the author

Insecure File Uploads

Upload surfaces are high risk: server-side execution (RCE), stored XSS, malware distribution, storage takeover, and DoS. Modern stacks mix direct-to-cloud uploads, background processors, and CDNs—authorization and validation must hold across every step.

Attack Surface

  • Web/mobile/API uploads, direct-to-cloud (S3/GCS/Azure) presigned flows, resumable/multipart protocols (tus, S3 MPU)
  • Image/document/media pipelines (ImageMagick/GraphicsMagick, Ghostscript, ExifTool, PDF engines, office converters)
  • Admin/bulk importers, archive uploads (zip/tar), report/template uploads, rich text with attachments
  • Serving paths: app directly, object storage, CDN, email attachments, previews/thumbnails

Reconnaissance

Surface Map

  • Endpoints/fields: upload, file, avatar, image, attachment, import, media, document, template
  • Direct-to-cloud params: key, bucket, acl, Content-Type, Content-Disposition, x-amz-meta-*, cache-control
  • Resumable APIs: create/init → upload/chunk → complete/finalize; check if metadata/headers can be altered late
  • Background processors: thumbnails, PDF→image, virus scan queues; identify timing and status transitions

Capability Probes

  • Small probe files of each claimed type; diff resulting Content-Type, Content-Disposition, and X-Content-Type-Options on download
  • Magic bytes vs extension: JPEG/GIF/PNG headers; mismatches reveal reliance on extension or MIME sniffing
  • SVG/HTML probe: do they render inline (text/html or image/svg+xml) or download (attachment)?
  • Archive probe: simple zip with nested path traversal entries and symlinks to detect extraction rules

Detection Channels

Server Execution

  • Web shell execution (language dependent), config/handler uploads (.htaccess, .user.ini, web.config) enabling execution
  • Interpreter-side template/script evaluation during conversion (ImageMagick/Ghostscript/ExifTool)

Client Execution

  • Stored XSS via SVG/HTML/JS if served inline without correct headers; PDF JavaScript; office macros in previewers

Header and Render

  • Missing X-Content-Type-Options: nosniff enabling browser sniff to script
  • Content-Type reflection from upload vs server-set; Content-Disposition: inline vs attachment

Process Side Effects

  • AV/CDR race or absence; background job status allows access before scan completes; password-protected archives bypass scanning

Core Payloads

Web Shells and Configs

  • PHP: GIF polyglot (starts with GIF89a) followed by <?php echo 1; ?>; place where PHP is executed
  • .htaccess to map extensions to code (AddType/AddHandler); .user.ini (auto_prepend/append_file) for PHP-FPM
  • ASP/JSP equivalents where supported; IIS web.config to enable script execution

Stored XSS

  • SVG with onload/onerror handlers served as image/svg+xml or text/html
  • HTML file with script when served as text/html or sniffed due to missing nosniff

MIME Magic Polyglots

  • Double extensions: avatar.jpg.php, report.pdf.html; mixed casing: .pHp, .PhAr
  • Magic-byte spoofing: valid JPEG header then embedded script; verify server uses content inspection, not extensions alone

Archive Attacks

  • Zip Slip: entries with ../../ to escape extraction dir; symlink-in-zip pointing outside target; nested zips
  • Zip bomb: extreme compression ratios to exhaust resources in processors

Toolchain Exploits

  • ImageMagick/GraphicsMagick legacy vectors (policy.xml may mitigate): crafted SVG/PS/EPS invoking external commands or reading files
  • Ghostscript in PDF/PS with file operators (%pipe%)
  • ExifTool metadata parsing bugs; overly large or crafted EXIF/IPTC/XMP fields

Cloud Storage Vectors

  • S3/GCS presigned uploads: attacker controls Content-Type/Disposition; set text/html or image/svg+xml and inline rendering
  • Public-read ACL or permissive bucket policies expose uploads broadly
  • Object key injection via user-controlled path prefixes
  • Signed URL reuse and stale URLs; serving directly from bucket without attachment + nosniff headers

Advanced Techniques

Resumable Multipart

  • Change metadata between init and complete (e.g., swap Content-Type/Disposition at finalize)
  • Upload benign chunks, then swap last chunk or complete with different source

Filename and Path

  • Unicode homoglyphs, trailing dots/spaces, device names, reserved characters to bypass validators
  • Null-byte truncation on legacy stacks; overlong paths; case-insensitive collisions overwriting existing files

Processing Races

  • Request file immediately after upload but before AV/CDR completes
  • Trigger heavy conversions (large images, deep PDFs) to widen race windows

Metadata Abuse

  • Oversized EXIF/XMP/IPTC blocks to trigger parser flaws
  • Payloads in document properties of Office/PDF rendered by previewers

Header Manipulation

  • Force inline rendering with Content-Type + inline Content-Disposition
  • Cache poisoning via CDN with keys missing Vary on Content-Type/Disposition

Bypass Techniques

Validation Gaps

  • Client-side only checks; relying on JS/MIME provided by browser
  • Trusting multipart boundary part headers blindly
  • Extension allowlists without server-side content inspection

Evasion Tricks

  • Double extensions, mixed case, hidden dotfiles, extra dots (file..png), long paths with allowed suffix
  • Multipart name vs filename vs path discrepancies; duplicate parameters and late parameter precedence

Special Contexts

Rich Text Editors

  • RTEs allow image/attachment uploads and embed links; verify sanitization and serving headers

Mobile Clients

  • Mobile SDKs may send nonstandard MIME or metadata; servers sometimes trust client-side transformations

Serverless and CDN

  • Direct-to-bucket uploads with Lambda/Workers post-processing; verify security decisions are not delegated to frontends
  • CDN caching of uploaded content; ensure correct cache keys and headers

Testing Methodology

  • Map the pipeline - Client → ingress → storage → processors → serving. Note where validation and auth occur
  • Identify allowed types - Size limits, filename rules, storage keys, and who serves the content
  • Collect baselines - Capture resulting URLs and headers for legitimate uploads
  • Exercise bypass families - Extension games, MIME/content-type, magic bytes, polyglots, metadata payloads, archive structure
  • Validate execution - Can uploaded content execute on server or client?

Validation

  • Demonstrate execution or rendering of active content: web shell reachable, or SVG/HTML executing JS when viewed
  • Show filter bypass: upload accepted despite restrictions with evidence on retrieval
  • Prove header weaknesses: inline rendering without nosniff or missing attachment
  • Show race or pipeline gap: access before AV/CDR; extraction outside intended directory
  • Provide reproducible steps: request/response for upload and subsequent access

False Positives

  • Upload stored but never served back; or always served as attachment with strict nosniff
  • Converters run in locked-down sandboxes with no external IO and no script engines
  • AV/CDR blocks the payload and quarantines; access before scan is impossible by design

Impact

  • Remote code execution on application stack or media toolchain host
  • Persistent cross-site scripting and session/token exfiltration via served uploads
  • Malware distribution via public storage/CDN; brand/reputation damage
  • Data loss or corruption via overwrite/zip slip; service degradation via zip bombs

Pro Tips

  • Keep PoCs minimal: tiny SVG/HTML for XSS, a single-line PHP/ASP where relevant
  • Always capture download response headers and final MIME; that decides browser behavior
  • Prefer transforming risky formats to safe renderings (SVG→PNG) rather than complex sanitization
  • In presigned flows, constrain all headers and object keys server-side
  • For archives, extract in a chroot/jail with explicit allowlist; drop symlinks and reject traversal
  • Test finalize/complete steps in resumable flows; many validations only run on init
  • Verify background processors with EICAR and tiny polyglots
  • When you cannot get execution, aim for stored XSS or header-driven script execution
  • Validate that CDNs honor attachment/nosniff

10. Document full pipeline behavior per asset type

Summary

Secure uploads are a pipeline property. Enforce strict type, size, and header controls; transform or strip active content; never execute or inline-render untrusted uploads; and keep storage private with controlled, signed access.

How to use it

Copy the folder

Take asdfgh1445/strix•不安全文件上传 from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.