Skip to content

Add DNS dangling scanner with examples, requirements, and readme#182

Open
Pnkcaht wants to merge 1 commit intokubernetes:mainfrom
Pnkcaht:scan-dangling-dns
Open

Add DNS dangling scanner with examples, requirements, and readme#182
Pnkcaht wants to merge 1 commit intokubernetes:mainfrom
Pnkcaht:scan-dangling-dns

Conversation

@Pnkcaht
Copy link

@Pnkcaht Pnkcaht commented Feb 7, 2026

What I Did

  • Added a proactive DNS dangling scanner for Netlify under sig-security-tooling/scan-dangling-dns/.
  • Implemented dns_scan.py with:
    • Safe HTTP requests with retries and timeouts
    • Signature-based detection of non-existent Netlify sites
    • JSON structured output for CI/Prow integration
    • Detailed logging and fail-safe design
  • Added example DNS records in examples/dns_records.yaml.
  • Added requirements.txt for dependency management (PyYAML and requests).
  • Added a fully descriptive README with Table of Contents, usage, YAML format, and contribution notes.
  • Verified scanner detects dangling Netlify records from the example YAML.

Related Issue

Test: DNS Dangling Scanner

Objective:
Verify that dns_scan.py correctly detects dangling Netlify DNS records from a sample YAML file.

Command executed:

python3 sig-security-tooling/scan-dangling-dns/dns_scan.py sig-security-tooling/scan-dangling-dns/examples/dns_records.yaml

Explanation:

  • The scanner reads examples/dns_records.yaml and iterates over all DNS records.

  • For each record pointing to a Netlify target, it performs a passive HTTP GET to check if the site exists.

  • Sites that respond with known Netlify “not found” signatures are flagged as dangling.

  • The scanner outputs INFO logs for each check and ERROR logs for detected dangling records.

  • A JSON structured list of dangling records is printed for CI/Prow integration.

  • Exit codes:

    • 0 → No dangling records

    • 2 → Dangling records detected

Result:

2026-02-06 19:54:49,231 - INFO - Checking Netlify target: docs.k8s.io -> kubernetes-docs.netlify.app
2026-02-06 19:54:52,486 - ERROR - Dangling Netlify DNS detected: docs.k8s.io -> kubernetes-docs.netlify.app
2026-02-06 19:54:52,486 - INFO - Checking Netlify target: dangling.k8s.io -> definitely-not-existing-k8s.netlify.app
2026-02-06 19:54:52,669 - ERROR - Dangling Netlify DNS detected: dangling.k8s.io -> definitely-not-existing-k8s.netlify.app
2026-02-06 19:54:52,670 - INFO - Checking Netlify target: old-preview.k8s.io -> old-k8s-preview-123.netlify.app
2026-02-06 19:54:53,070 - ERROR - Dangling Netlify DNS detected: old-preview.k8s.io -> old-k8s-preview-123.netlify.app
2026-02-06 19:54:53,070 - INFO - Checking Netlify target: schema-test.k8s.io -> missing-schema-test.netlify.app
2026-02-06 19:54:53,258 - ERROR - Dangling Netlify DNS detected: schema-test.k8s.io -> https://missing-schema-test.netlify.app
2026-02-06 19:54:53,258 - INFO - Checking Netlify target: cname-style.k8s.io -> alias-to-something.netlify.app
2026-02-06 19:54:53,441 - ERROR - Dangling Netlify DNS detected: cname-style.k8s.io -> alias-to-something.netlify.app
2026-02-06 19:54:53,441 - ERROR - Dangling DNS records detected:
[
  {
    "hostname": "docs.k8s.io",
    "target": "kubernetes-docs.netlify.app",
    "provider": "netlify"
  },
  {
    "hostname": "dangling.k8s.io",
    "target": "definitely-not-existing-k8s.netlify.app",
    "provider": "netlify"
  },
  {
    "hostname": "old-preview.k8s.io",
    "target": "old-k8s-preview-123.netlify.app",
    "provider": "netlify"
  },
  {
    "hostname": "schema-test.k8s.io",
    "target": "https://missing-schema-test.netlify.app",
    "provider": "netlify"
  },
  {
    "hostname": "cname-style.k8s.io",
    "target": "alias-to-something.netlify.app",
    "provider": "netlify"
  }
]

Conclusion:
The scanner successfully detected all dangling Netlify DNS records in the example YAML.
Logs are detailed, and JSON output is ready for CI/Prow automation.

Diagram

flowchart TD
    A[Load DNS records from YAML] --> B{For each record}
    B --> C{Is target a Netlify site?}
    C -- No --> B
    C -- Yes --> D[Normalize hostname]
    D --> E[Perform HTTP GET with retries]
    E --> F{Check for dangling signatures}
    F -- Found --> G[Log ERROR & add to dangling list]
    F -- Not found --> H[Log INFO - site exists]
    G --> B
    H --> B
    B --> I[Print JSON of dangling records]
    I --> J[Exit with code 0 or 2]
Loading

Remaining future step:

Investigate flagged records and remove or reassign DNS entries to prevent subdomain takeover

Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Pnkcaht
Once this PR has been reviewed and has the lgtm label, please assign iancoldwater for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 7, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @Pnkcaht. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 7, 2026
@PushkarJ
Copy link
Member

/ok-to-test
/cc tabbysable

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scanning and private triage of dangling DNS records

3 participants