Completes AXFR security scanning

This commit is contained in:
Alicia Sykes committed 2025-10-07 22:15:12 +01:00
1 parent eaf8bd883d
commit 3a77cdfc59
5 files changed
+181 -51

No files matched your search

+12 -1
View File
@@ -1193,7 +1193,18 @@ export const SUB_NAV: Record<string, (NavItem | NavGroup)[]> = {
label: 'AXFR Security Tester',
description: 'Test if DNS zone transfers are improperly exposed - detect critical security vulnerabilities',
icon: 'zone-transfer-safe',
keywords: ['axfr', 'zone', 'transfer', 'security', 'vulnerability', 'dns', 'leak', 'audit', 'test', 'nameserver'],
keywords: [
'axfr',
'zone',
'transfer',
'security',
'vulnerability',
'dns',
'leak',
'audit',
'test',
'nameserver',
],
},
{
href: makePath('/diagnostics/dns/query-performance'),
+5 -10
View File
@@ -38,8 +38,7 @@ However, if AXFR is misconfigured to allow transfers from any source, it becomes
{
risk: 'Internal IP Exposure',
severity: 'Medium',
description:
'Private IP addresses and internal network topology revealed through zone records.',
description: 'Private IP addresses and internal network topology revealed through zone records.',
impact: 'Helps attackers understand internal network architecture',
},
],
@@ -136,26 +135,22 @@ VALUES (1, 'ALLOW-AXFR-FROM', '192.0.2.1');`,
practices: [
{
practice: 'Restrict Zone Transfers',
description:
'Only allow AXFR from authorized secondary nameservers. Never allow unrestricted transfers.',
description: 'Only allow AXFR from authorized secondary nameservers. Never allow unrestricted transfers.',
priority: 'Critical',
},
{
practice: 'Use TSIG Authentication',
description:
'Implement TSIG (Transaction Signature) for authenticated zone transfers between servers.',
description: 'Implement TSIG (Transaction Signature) for authenticated zone transfers between servers.',
priority: 'High',
},
{
practice: 'Regular Security Audits',
description:
'Periodically test your nameservers for AXFR vulnerabilities using tools like this one.',
description: 'Periodically test your nameservers for AXFR vulnerabilities using tools like this one.',
priority: 'High',
},
{
practice: 'Minimize Public DNS Records',
description:
"Don't publish internal hostnames or private infrastructure details in public DNS zones.",
description: "Don't publish internal hostnames or private infrastructure details in public DNS zones.",
priority: 'Medium',
},
{
@@ -1,8 +1,11 @@
import { json, error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
import { promises as dns } from 'node:dns';
// @ts-expect-error - Node.js core modules work at runtime
import { exec } from 'child_process';
// @ts-expect-error - Node.js core modules work at runtime
import { promisify } from 'util';
// @ts-expect-error - Node.js core modules work at runtime
import { promises as dns } from 'dns';
const execAsync = promisify(exec);
@@ -66,9 +69,7 @@ async function testAXFR(domain: string, nameserver: string, ip: string): Promise
const { stdout, stderr } = await Promise.race([
execAsync(command, { maxBuffer: 1024 * 1024 * 5 }), // 5MB max
new Promise<never>((_, reject) =>
setTimeout(() => reject(new Error('AXFR query timeout')), AXFR_TIMEOUT_MS)
),
new Promise<never>((_, reject) => setTimeout(() => reject(new Error('AXFR query timeout')), AXFR_TIMEOUT_MS)),
]);
const endTime = performance.now();
@@ -76,18 +77,17 @@ async function testAXFR(domain: string, nameserver: string, ip: string): Promise
const output = stdout + stderr;
// Check for transfer success indicators
if (output.includes('Transfer failed') || output.includes('failed')) {
// Check for connection reset (SECURE - actively refusing)
if (output.includes('connection reset')) {
return {
nameserver,
ip,
vulnerable: false,
error: 'Transfer refused (secure)',
responseTime,
};
}
// Check for timeout
// Check for timeout/connection errors (can't determine security)
if (output.includes('connection timed out') || output.includes('no servers could be reached')) {
return {
nameserver,
@@ -98,6 +98,16 @@ async function testAXFR(domain: string, nameserver: string, ip: string): Promise
};
}
// Check for transfer refused (SECURE - proper configuration)
if (output.includes('Transfer failed') || output.includes('failed') || output.includes('refused')) {
return {
nameserver,
ip,
vulnerable: false,
responseTime,
};
}
// Parse records from output
const lines = output.split('\n').filter((line: string) => {
const trimmed = line.trim();
@@ -128,18 +138,28 @@ async function testAXFR(domain: string, nameserver: string, ip: string): Promise
}
}
// No records returned - secure
// No records returned - secure (transfer properly refused)
return {
nameserver,
ip,
vulnerable: false,
error: 'Transfer refused (secure)',
responseTime,
};
} catch (err: any) {
const endTime = performance.now();
const responseTime = Math.round((endTime - startTime) * 100) / 100;
// Check if error output contains connection reset (SECURE)
const errorOutput = (err.stderr || err.stdout || err.message || '').toLowerCase();
if (errorOutput.includes('connection reset')) {
return {
nameserver,
ip,
vulnerable: false,
responseTime,
};
}
let errorMsg = 'Unknown error';
if (err.message?.includes('timeout')) {
errorMsg = 'Query timeout';
@@ -224,7 +244,7 @@ export const POST: RequestHandler = async ({ request }) => {
responseTime: 0,
};
}
})
}),
);
// Calculate summary
@@ -40,10 +40,15 @@
});
const examples = [
{ domain: 'zonetransfer.me', description: 'Intentionally vulnerable test domain' },
{ domain: 'google.com', description: 'Secure major site' },
{ domain: 'cloudflare.com', description: 'Secure DNS provider' },
{ domain: 'github.com', description: 'Secure tech company' },
{ domain: 'bbc.co.uk', description: '' },
{ domain: 'zonetransfer.me', description: '' },
{ domain: 'networkingtoolbox.net', description: '' },
{ domain: 'amazon.com', description: '' },
{ domain: 'wikipedia.org', description: '' },
{ domain: 'github.com', description: '' },
{ domain: 'gov.uk', description: '' },
{ domain: 'proton.me', description: '' },
{ domain: 'loveholidays.com', description: '' },
];
async function testAXFR() {
@@ -147,7 +152,13 @@
</div>
<!-- Input Form -->
<form class="inline-form" onsubmit={(e) => { e.preventDefault(); testAXFR(); }}>
<form
class="inline-form"
onsubmit={(e) => {
e.preventDefault();
testAXFR();
}}
>
<div class="form-group flex-grow">
<label for="domain">Domain Name</label>
<input
@@ -156,7 +167,9 @@
bind:value={domain}
placeholder="example.com"
disabled={loading}
oninput={() => { selectedExampleIndex = null; }}
oninput={() => {
selectedExampleIndex = null;
}}
aria-invalid={!isInputValid}
/>
</div>
@@ -192,8 +205,8 @@
<div>
<strong>Critical Security Vulnerability Detected!</strong>
<p>
{results.summary.vulnerable} nameserver{results.summary.vulnerable > 1 ? 's' : ''} allowed
unrestricted zone transfer. Your entire DNS zone is exposed to anyone.
{results.summary.vulnerable} nameserver{results.summary.vulnerable > 1 ? 's' : ''} allowed unrestricted zone
transfer. Your entire DNS zone is exposed to anyone.
<strong>Immediate action required!</strong>
</p>
</div>
@@ -259,10 +272,10 @@
</div>
</div>
<div class="nameserver-status">
<span class="response-time">{ns.responseTime}ms</span>
<span class="status-badge status-{getStatusColor(ns)}">
{getStatusText(ns)}
</span>
<span class="response-time">{ns.responseTime}ms</span>
</div>
</div>
@@ -280,8 +293,7 @@
onclick={() => toggleRecords(ns.nameserver)}
>
<Icon name="chevron-right" size="xs" />
{expandedRecords.has(ns.nameserver) ? 'Hide' : 'Show'} exposed records
({ns.records.length} of {ns.recordCount})
{expandedRecords.has(ns.nameserver) ? 'Hide' : 'Show'} exposed records ({ns.records.length} of {ns.recordCount})
</button>
{#if expandedRecords.has(ns.nameserver)}
@@ -315,15 +327,17 @@
<!-- Test Metadata -->
<div class="test-metadata">
<p>
<strong>Domain:</strong> {results.domain} •
<strong>Tested:</strong> {new Date(results.timestamp).toLocaleString()}
<strong>Domain:</strong>
{results.domain} •
<strong>Tested:</strong>
{new Date(results.timestamp).toLocaleString()}
</p>
</div>
{/if}
</div>
<!-- Educational Content -->
<section class="card educational-part">
<section class="card educational-part">
<div class="card info-card">
<h2>{axfrContent.sections.whatIsAXFR.title}</h2>
<p>{axfrContent.sections.whatIsAXFR.content}</p>
@@ -354,13 +368,21 @@
{#each axfrContent.sections.interpretation.statuses as status (status.status)}
<div class="status-explanation status-{status.color}">
<div class="status-header">
<Icon name={status.status === 'Vulnerable' ? 'alert-circle' : status.status === 'Secure' ? 'shield-check' : 'alert-triangle'} size="sm" />
<Icon
name={status.status === 'Vulnerable'
? 'alert-circle'
: status.status === 'Secure'
? 'shield-check'
: 'alert-triangle'}
size="sm"
/>
<h4>{status.status}: {status.meaning}</h4>
</div>
<p>{status.description}</p>
<div class="status-action">
<Icon name="arrow-right" size="xs" />
<strong>Action:</strong> {status.action}
<strong>Action:</strong>
{status.action}
</div>
</div>
{/each}
@@ -464,6 +486,74 @@
}
}
.alert {
display: flex;
align-items: flex-start;
gap: var(--spacing-md);
padding: var(--spacing-md);
border-radius: var(--radius-md);
border-left: 4px solid;
margin: var(--spacing-lg) 0;
:global(.icon) {
flex-shrink: 0;
margin-top: 2px;
}
div {
flex: 1;
min-width: 0;
}
strong {
display: block;
font-size: var(--font-size-md);
margin-bottom: var(--spacing-xs);
}
p {
margin: 0;
font-size: var(--font-size-sm);
line-height: 1.5;
}
&.alert-error {
background: color-mix(in srgb, var(--color-error) 10%, var(--bg-primary));
border-left-color: var(--color-error);
color: var(--color-error);
:global(.icon) {
color: var(--color-error);
}
strong {
color: var(--color-error);
}
p {
color: var(--text-primary);
}
}
&.alert-success {
background: color-mix(in srgb, var(--color-success) 10%, var(--bg-primary));
border-left-color: var(--color-success);
color: var(--color-success);
:global(.icon) {
color: var(--color-success);
}
strong {
color: var(--color-success);
}
p {
color: var(--text-primary);
}
}
}
.stats-summary {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
@@ -523,24 +613,29 @@
}
.nameserver-card {
background: var(--bg-secondary);
background: var(--bg-tertiary);
border-radius: var(--radius-md);
padding: var(--spacing-md);
border-left: 4px solid var(--border-primary);
&.status-error {
border-left-color: var(--color-error);
background: color-mix(in srgb, var(--color-error) 6%, var(--bg-secondary));
.nameserver-info :global(.icon) {
color: var(--color-error);
}
// background: color-mix(in srgb, var(--color-error) 6%, var(--bg-secondary));
}
&.status-success {
border-left-color: var(--color-success);
background: color-mix(in srgb, var(--color-success) 6%, var(--bg-secondary));
.nameserver-info :global(.icon) {
color: var(--color-success);
}
// background: color-mix(in srgb, var(--color-success) 6%, var(--bg-secondary));
}
&.status-warning {
border-left-color: var(--color-warning);
background: color-mix(in srgb, var(--color-warning) 6%, var(--bg-secondary));
.nameserver-info :global(.icon) {
color: var(--color-warning);
}
// background: color-mix(in srgb, var(--color-warning) 6%, var(--bg-secondary));
}
.nameserver-header {
@@ -587,12 +682,12 @@
&.status-error {
background: var(--color-error);
color: white;
color: var(--bg-primary);
}
&.status-success {
background: var(--color-success);
color: white;
color: var(--bg-primary);
}
&.status-warning {
@@ -749,7 +844,7 @@
&.severity-high {
background: var(--color-error);
color: white;
color: var(--bg-primary);
}
&.severity-medium {
@@ -82,6 +82,15 @@ describe('AXFR Security Tester API', () => {
expect(status).toBe(200);
expect(data.summary.vulnerable).toBe(0);
});
it('should handle connection reset as secure', async () => {
const { status, data } = await makeRequest('loveholidays.com');
expect(status).toBe(200);
expect(data.summary.vulnerable).toBe(0);
// Connection reset should be counted as secure, not error
expect(data.summary.secure).toBeGreaterThan(0);
});
});
describe('Vulnerable Test Domain', () => {