unit363

Security Engineer. Automating things. Breaking things.

AI Attacks Cheat Sheet

Attacks on AI – Cheat Sheet

Scope: conceptual overview (workflow, basic attack classes, how they work, defenses). No weaponized payloads. Verified against web sources (Oct 2026): OWASP Top 10 for LLM Applications 2025 (list names/order), MITRE ATLAS (exists, ATT&CK-style, ~16 tactics; technique counts differ between sources/versions, so check atlas.mitre.org for the current number). Marked [memory] = recalled from general knowledge, not checked against a source in this session.


1. Two worlds: classic ML vs. LLM apps

Classic ML (classifiers, vision, fraud)LLM / GenAI apps (chatbot, RAG, agents)
Typical targetsModel weights, training data, decision boundaryPrompt, context, tools, retrieval data, output handling
Typical attacksEvasion, poisoning, extraction, inferencePrompt injection, jailbreak, leakage, excessive agency
Core weaknessModel learns statistical patterns, not intentInstructions and data share one channel (natural language)

Key idea: an LLM cannot reliably separate instructions from data. This is the root cause of most LLM attacks.

Bash Cheat Sheet

Wrong Windows copy

sed -i 's/\r$//' file

Test setup

Every example here was run on the 8-line access.log below, and the output shown is the real output. Tested with GNU sed 4.9, GNU grep 3.11 and mawk 1.3.4 on Linux.

192.168.1.10 - alice [27/Oct/2026:10:00:01 +0100] "GET /index.html HTTP/1.1" 200 1024
192.168.1.11 - bob [27/Oct/2026:10:00:05 +0100] "POST /login HTTP/1.1" 401 312
10.0.0.5 - - [27/Oct/2026:10:01:10 +0100] "GET /admin HTTP/1.1" 403 210
192.168.1.10 - alice [27/Oct/2026:10:02:00 +0100] "GET /img/a.png HTTP/1.1" 200 5120
10.0.0.5 - - [27/Oct/2026:10:02:30 +0100] "POST /login HTTP/1.1" 401 312
10.0.0.5 - - [27/Oct/2026:10:02:35 +0100] "POST /login HTTP/1.1" 401 312
172.16.4.2 - carol [27/Oct/2026:10:03:00 +0100] "GET /api/v1/items HTTP/1.1" 500 87
192.168.1.11 - bob [27/Oct/2026:10:04:00 +0100] "POST /login HTTP/1.1" 200 640

Field numbers used below (space-delimited): $1 client IP, $3 user, $9 HTTP status, $NF response bytes (last field).

Certificates Cheat Sheet

1. Scan hosts for certificates

1.1 Find ports with certificates (Task 1)

nmap -p- -sV --script ssl-cert <host>        # ALL ports, detect TLS on odd ports  [V: -sV helps find TLS on unexpected ports]
nmap -sV --script ssl-cert -p 443,8443 <host>
nmap -p- -T4 <host> -oN ports.txt            # fast pass first, then -sV on open ports
  • tcpwrapped = connection closed right after the handshake (TCP wrapper/filter), not probed for TLS. Retry with -sV or openssl s_client -connect host:port [R].
  • In the nmap output, ssl/http means HTTPS, plain http means no TLS. Only list ports that really present a certificate.

1.2 nmap NSE scripts for TLS [V]

ScriptPurpose
ssl-certDump certificate: subject, issuer, validity, key, SANs
ssl-enum-ciphersProtocols + cipher suites with grade A-F (based on the SSL Labs rating guide). Intrusive/noisy. Does not test SSLv2.
sslv2Check SSLv2 support
ssl-dh-paramsWeak Diffie-Hellman groups (Logjam)
ssl-heartbleedHeartbleed
ssl-poodlePOODLE (SSLv3 CBC)
ssl-ccs-injectionCCS injection
nmap -sV --script ssl-cert,ssl-enum-ciphers,ssl-dh-params -p 443 <host>
nmap -sV --script "ssl-*,sslv2" -p 443 <host>

1.3 sslscan [R] (check sslscan --help for your version)

sslscan <host>:443                       # protocols, ciphers, cert, DH size, compression, renegotiation
sslscan --show-certificate <host>:443
sslscan --ssl2 --ssl3 --tls10 --tls11 <host>   # per-version flags (also --tls12 / --tls13)
sslscan --no-colour <host>:443 > sslscan.txt   # clean text for the report
sslscan --starttls-smtp <host>:25

Reading the output: Accepted = enabled on the server, Preferred = chosen first. Look at: protocol list, cipher list (weak ones), DHE xxxx bits, certificate block, TLS compression, heartbleed.

CSP & Session Cookies Cheat Sheet

1. What is CSP?

Content Security Policy is a browser-enforced allowlist that tells the browser which sources of content (scripts, styles, images, frames, …) a page may load or execute.

  • Delivered via HTTP response header (preferred) or <meta http-equiv> (limited).
  • Defense in depth, mainly against XSS and data injection. Also helps with clickjacking (frame-ancestors) and mixed content.
  • It does not fix the underlying injection bug. It limits the damage.
  • Enforced by the browser, not the server. Non-supporting clients ignore it.
Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.example.com

Headers

HeaderPurpose
Content-Security-PolicyEnforce: violations are blocked and reported
Content-Security-Policy-Report-OnlyMonitor: violations are only reported, nothing blocked. Use for rollout
  • Multiple policies are allowed. All must pass (the most restrictive wins).
  • Syntax: directives separated by ;, sources within a directive separated by spaces.

2. Common directives

Fetch directives (what can load)

DirectiveControls
default-srcFallback for most other fetch directives
script-srcJavaScript (also script-src-elem, script-src-attr)
style-srcCSS (also style-src-elem, style-src-attr)
img-srcImages and favicons
font-srcFonts
connect-srcfetch/XHR, WebSocket, EventSource, sendBeacon
media-src<audio>, <video>
object-src<object>, <embed> (set to 'none')
frame-srcSources for <iframe> / <frame> content you embed
child-srcFrames and workers (legacy-ish)
worker-srcWorkers and service workers
manifest-srcWeb app manifest

Document / navigation directives (no fallback to default-src)

DirectiveControls
base-uriAllowed <base> URLs. Set 'self' or 'none'
form-actionWhere forms may submit
frame-ancestorsWho may embed your page (replaces X-Frame-Options)
sandboxApplies iframe-sandbox-like restrictions to the page

Other

DirectivePurpose
upgrade-insecure-requestsRewrites http:// subresource URLs to https://
report-toReporting API group name (modern)
report-uriLegacy reporting endpoint (deprecated but still widely used)
require-trusted-types-for 'script' / trusted-typesDOM XSS sink protection (Trusted Types)

3. Source values

ValueMeaning
'none'Nothing allowed
'self'Same origin (scheme + host + port)
https:Any HTTPS URL (scheme source)
https://cdn.example.comSpecific host
*.example.comWildcard subdomain
data: / blob:Data / blob URIs (data: in script-src is dangerous)
'unsafe-inline'Allows inline scripts/styles. Defeats most XSS protection
'unsafe-eval'Allows eval() and similar. Avoid
'nonce-<base64>'Allows elements carrying a matching nonce attribute
'sha256-<base64>'Allows inline content with a matching hash (also sha384/sha512)
'strict-dynamic'Trust propagates to scripts loaded by already-trusted scripts. Host allowlist and 'unsafe-inline' are ignored
'unsafe-hashes'Allows hashed inline event handlers
'report-sample'Includes a code sample in violation reports

Rules to remember

  • If a nonce or hash is present in a directive, 'unsafe-inline' is ignored by modern browsers (intentional backward-compat trick).
  • Nonces must be unique per response, unguessable (≥128 bits random), never static.
  • Host allowlists are weak: JSONP endpoints and old Angular/CDN gadgets on allowed hosts can bypass them. Prefer nonce + 'strict-dynamic'.
  • default-src is only a fallback. A specific directive replaces it (no merging).

4. Example policies

Content-Security-Policy:
  script-src 'nonce-{RANDOM}' 'strict-dynamic' https: 'unsafe-inline';
  object-src 'none';
  base-uri 'none';
  frame-ancestors 'self';
  form-action 'self';
  report-to csp-endpoint

(https: and 'unsafe-inline' are only fallbacks for old browsers. Modern ones ignore them when nonce + strict-dynamic are present.)

EML Cheat Sheet

1. Workflow (do it in this order, every time)

  1. Integrity first: check the hash of the delivered file (md5sum c7-email.zip / sha256sum), compare with the given value, and note it in the report.
  2. Open the raw file in a text editor (never only a mail client). Note the top-level Content-Type.
  3. Overview: From, To, Cc, Reply-To, Return-Path, Subject, Date, Message-ID.
  4. Routing: read Received: headers bottom to top. Per hop write down: FQDN, IP, protocol (with ...), timestamp.
  5. Trust boundary: only headers added by servers you trust (your own provider, topmost block) are reliable. Everything below can be forged.
  6. Authentication: Authentication-Results, Received-SPF, DKIM-Signature, ARC-*. Check alignment of From domain, Return-Path domain and DKIM d=.
  7. Who owns the IPs? WHOIS / AS lookup per hop (country, owner). This is the evidence for “where is the server”.
  8. Encryption: E2E (MIME structure), transit (ESMTPS, TLS version/cipher), at rest (only provider claims, e.g. vendor headers).
  9. Body/attachments: decode, list real URLs, hash attachments, never open outside an isolated VM.
  10. Report: for every claim give header line + source, plus the command/tool used. No “probably” without evidence.

Quick grep set: