Repository navigation
Description
Problem
Crawl4AI had critical SSRF and RCE bugs in 0.8.x and 0.9.0, and 6 more advisories were fixed on 2026-10-15 (https://api.github.com/repos/unclecode/crawl4ai/security-advisories, read 2026-11-07). The research found two open points that no document settles: whether POST /md and GET /llm/{url} run the same destination check as /html, /screenshot and /pdf; and whether the proxy blocks cluster-internal names (*.svc, *.cluster.local) or only the metadata and RFC 1918 ranges. Two sources also disagree on the status code for the metadata address (400 and 403). Nothing in the repository would fail if a later digest bump removed one of these controls.
Expected
A live-marked test (skips where the cluster or a port-forward is missing, as other live tests do) that sends, with the real token read from the keyring, requests to /md, /html, /screenshot, /pdf and /llm/... for these targets: http://169.254.169.254/, http://localhost/, http://kubernetes.default.svc/, the cluster DNS name of the Crawl4AI Service itself, the cluster DNS name of the Service roadmap-service, and a redirect from a public test host to a private address if a safe public test host exists. Each must give a refusal and no body. It also checks that a request without the token gets 401 or 403 on every route except /health. The test file names the image digest it was written for. If a control is missing, the issue follows rule 2: file the evidence upstream and as a comment on the manifests issue, and write no compensating code.
Acceptance criteria
- The test fails on a Crawl4AI start with
CRAWL4AI_ALLOW_INTERNAL_URLS=true(run once by hand and cite the output in the PR comment), and passes on the pinned digest. - The NetworkPolicy layer is tested on its own: a throwaway pod with the label of
crawl4aicannot connect to a private ClusterIP or to the metadata address. - The test runs in the devcontainer and on the GitHub runner, or skips with a reason (owner rule 2026-10-24: no host changes on runners).
- The PR comment lists the result per route and per target. No private host name or address appears in the file or the comment (use
<service-ip>style roles).
Existing tool considered
The project's live-test marker and the HTTP client; kubectl run for the throwaway pod. No new scanner.
Related
Depends on the manifests issue. Related: SECURITY.md (egress, SSRF). Its result is the evidence for ## Feasibility of the manifests change. Run it again at each digest bump.
Proposed design
Problem statement
Crawl4AI had critical SSRF and RCE bugs, and 6 more advisories were fixed on 2026-10-15. A later digest bump could remove a control, and nothing in the repository would fail. No document settles whether /md and /llm/{url} check their destination, and whether the proxy blocks cluster-internal names. The test floor fakes all network and keyring edges and forbids a skip on host state, so a live pytest test cannot reach the service. This item adds a devops k8s crawl4ai-check command that sends each route to each internal target, checks the NetworkPolicy layer with a throwaway pod, and prints a report table. A missing control is filed upstream and on #3884; the change adds no compensating code. The result is the evidence for the ## Feasibility section of #3884, and a person runs the command again at each digest bump. The manual run with CRAWL4AI_ALLOW_INTERNAL_URLS=true and the redirect case are filed as #4018 and #4019.
Acceptance criteria
Requirement: Dry run
The command SHALL print each request that it would make and MUST make no request with --dry-run.
Scenario: Dry run lists the requests
- WHEN A person runs
devops k8s crawl4ai-check --dry-runwith the process, HTTP and keyring fakes installed - THEN The output lists the port-forward, the 25 route requests, the no-token requests and the
kubectl run, and the process fake records no call.
Requirement: Route and target matrix
The command SHALL send one request to each of the five routes for each of the five internal target roles.
Scenario: Twenty-five cases
- WHEN The command runs with the HTTP fake that answers 400 with the short refusal message
- THEN The HTTP fake records 25 token-bearing requests, one for each of
/md,/html,/screenshot,/pdfand/llm/{url}against the metadata, loopback,kubernetes,crawl4aiandroadmap-serviceroles, and the command exits 0.
Requirement: Refusal of an internal target
The command MUST count a status of 400 or 403 with a body that holds no page content as a refusal and MUST exit 1 on any other answer.
Scenario: A served page
- WHEN The HTTP fake answers one route with status 200 and a page body
- THEN The command exits 1 and names that route and its target role in the output; a 400 with the short refusal message passes.
Requirement: Missing token
The command MUST send one request to each route without the token header and MUST require 401 or 403 on every route except /health.
Scenario: No token header
- WHEN The command runs with the HTTP fake that answers 401 without the header and 200 for
/health - THEN The command exits 0, and the same run with a fake that answers 200 on
/mdwithout the header exits 1.
Requirement: Token from the keyring
The command MUST read the token through the keyring seam and MUST NOT print it.
Scenario: Keyring entry absent
- WHEN The keyring fake holds no
crawl4ai_api_tokenentry - THEN The command exits 1 with a message that names
crawl4ai_api_token, and no token value appears in its output.
Requirement: Pinned digest
An offline gate check MUST compare the digest in k8s/devops/crawl4ai/deployment.yaml with the digest that the command names.
Scenario: Digest bump
- WHEN The check reads a Deployment whose digest differs from the digest that the command names
- THEN The check fails and names both digests and the command that a person runs again.
Requirement: No private host or address
The command module and its output MUST name each target by a role and MUST NOT hold a private host name or a private address.
Scenario: Committed addresses
- WHEN The committed-addresses invariant runs and the new module check runs
- THEN The command module and its output hold no RFC 1918 address, no metadata address literal, no
.lanor.localhost, and each target appears as a role such as<crawl4ai-service>.
Requirement: NetworkPolicy layer
The command SHALL start a throwaway pod that carries the crawl4ai label in namespace devops, SHALL report a block for each destination that the pod cannot reach, and SHALL delete the pod after the probes.
Scenario: Throwaway pod
- WHEN The command runs with a process fake that answers the
kubectl runcall and records the connection probes - THEN The recorded
kubectl runcarriesapp.kubernetes.io/name=crawl4aiand namespacedevops, the recorded delete names the pod, and the output holds one row for the private ClusterIP role and one for the metadata role.
Requirement: Hermetic tests
The tests of the command MUST run with the process, HTTP and keyring fakes and MUST NOT skip on host state.
Scenario: No cluster
- WHEN The suite runs on a host with no cluster and no keyring entry
- THEN Each test of the command runs to a pass or a fail, none skips, and no test opens a socket or reads the OS keyring.
Requirement: Report table
The command MUST print one row for each route and target role with its status and its body length.
Scenario: Report rows
- WHEN The command runs against the HTTP fake for all 25 cases
- THEN The output holds 25 rows, each row names the route, the target role, the status and the body length, and no row holds a private host name or address.
Existing Tool Considered
No alternatives check has run on this item. The open, maintained tool that covers part of the need is kubectl (Apache-2.0), for the port-forward and the throwaway pod, and the project's own devops_cli.http.entry covers the requests. Neither knows the Crawl4AI route matrix, the refusal status or the report, and no open, maintained scanner tests a running Crawl4AI service. The change builds one command module and one gate check: about 400 lines, an estimated 70k tokens to write, an estimated 10k tokens for each later fix, an estimated 5k tokens a year to keep, and one day of elapsed time. An offline NetworkPolicy checker reads the policy document only and does not test the running cluster, so it does not remove this cost.
Key questions
- Which shape delivers the check: a live pytest test, a
devops k8scommand, or a manual procedure ink8s/README.md?: Adevops k8s crawl4ai-checkcommand. The test floor fakes all network and keyring edges and forbids a skip on host state, so a live pytest test cannot reach the service. The body asks for a run at each digest bump, so a repeatable command is better than a manual procedure. (best practice) [sources: docs/TESTING.md:68, docs/TESTING.md:73, tests/conftest.py:382, AGENTS.md:11]- Rejected: Live pytest test.
tests/conftest.pyrefuses a loopback connect and denies the keyring, anddocs/TESTING.mdforbids a skip on host state. - Chosen:
devops k8scommand. It runs outside the test floor, its tests use the process, HTTP and keyring fakes, and a person repeats it at each digest bump. - Rejected: Manual procedure in
k8s/README.md. It leaves no automated check, and the body asks for a run at each digest bump.
- Rejected: Live pytest test.
- How does the check treat the two points that no document settles?: The command measures both. It sends each of the five routes to each of the five target roles and records the status and the body length. A route that returns page content fails the command and gives the evidence for the upstream report and a comment on feat(k8s): run Crawl4AI 0.9.5 in namespace devops #3884; the change adds no compensating code. (best practice) [sources: k8s/README.md:807, SECURITY.md:18, openspec/changes/archive/2026-11-07-3884-crawl4ai-manifests/proposal.md:45]
- Chosen: Measure each route and assert a refusal. It tests the widest surface, and a served body is the risk that the item guards.
- Rejected: Assume
/mdand/llm/{url}match/html. No document settles the point, so the assumption would hide a missing control. - Rejected: Leave
/mdand/llm/{url}out. They are the routes with the least evidence, so a gap would stay untested.
- Which statuses count as a refusal, and what body is allowed?: A status of 400 or 403 is a refusal. The body must hold no page content: the pinned image returns HTTP 400 with the short message
URL blocked (SSRF protection)(k8s/README.md:812; archived proposal line 45), so an empty body cannot be required. A 2xx status, a 5xx status, or a body with page content fails. The report records the status and the body length, so a 403 from another layer stays visible. (best practice) [sources: k8s/README.md:812, openspec/changes/archive/2026-11-07-3884-crawl4ai-manifests/proposal.md:45]- Chosen: 400 or 403 with no page content. The pinned image documents 400 with a short refusal message, 403 is the second reported code, and the body guard rejects a served page.
- Rejected: 400 or 403 with an empty body. The pinned image returns
URL blocked (SSRF protection), so this would fail on the correct image. - Rejected: Any non-2xx status. A 500 is a fault and not a refusal, so a crash would pass.
- How does the command get the Crawl4AI API token?: The command reads the token through the keyring seam from the entry
crawl4ai_api_token, and it exits 1 with a message when the entry is absent. It never prints the token. (best practice) [sources: SECURITY.md:17, src/devops_cli/config/settings.py:2003, src/devops_cli/k8s/cluster_secrets.py:202, k8s/README.md:603]- Chosen: Keyring seam. Rule 1 of
SECURITY.mdputs each secret in a secret store, and the cluster secret table already readscrawl4ai_api_tokenfrom the keyring. - Rejected: Environment variable. The value would pass through the job environment and the trace, and rule 1 forbids that.
- Rejected:
kubectl get secret. It needs read access to a Secret and puts the value in the process.
- Chosen: Keyring seam. Rule 1 of
- How does the command reach the running service?: The command starts a
kubectl port-forwardsubprocess to thecrawl4aiService and sends each request throughdevops_cli.http.entry.http_clientatEgressLevel.LOOPBACK. (best practice) [sources: SECURITY.md:18, src/devops_cli/http/entry.py:52, k8s/devops/crawl4ai/service.yaml:9, k8s/README.md:811]- Chosen: Port-forward. The command process owns the forward, and the project's HTTP entry checks the loopback level.
- Rejected: In-cluster Job. It needs a Job, a ServiceAccount and a policy change, and it costs more than the check.
- Rejected: The Service address from the workstation. It needs a route into the cluster that the project does not have.
- How does the command name each target without a private host name or address in the source?: The command composes the Service names at run time from the namespace, the Service name and the
svcdomain; the pod resolver completes the name with the cluster domain. The metadata target is a named constant besideCONST_CLOUD_METADATA_IPV4insrc/devops_cli/config/constants.pythat the command imports, so the command module holds no address literal. The report names each target by a role such as<crawl4ai-service>. (best practice) [sources: AGENTS.md:18, SECURITY.md:29, tests/invariants/test_committed_addresses.py:67, src/devops_cli/config/constants.py:2929]- Chosen: Compose each name at run time. It keeps the host names and the address out of the command module and follows rule 8 of
SECURITY.md. - Rejected: Literal FQDN in the source. It breaks rule 8 and the committed-addresses invariant.
- Rejected: Read each address from
kubectl get svc. A failure would then name no target role.
- Chosen: Compose each name at run time. It keeps the host names and the address out of the command module and follows rule 8 of
- How does the check notice a change of the pinned digest?: The command names the digest in a constant, and a new
check_*in thek8srow (tests/gate/k8s_checks/devops_runtime.py) compares it with the image ink8s/devops/crawl4ai/deployment.yaml. The existing check only asserts the image starts withunclecode/crawl4ai:; the new check compares the full digest. A bump fails the row until a person runs the command and updates the constant. (best practice) [sources: k8s/devops/crawl4ai/deployment.yaml:50, tests/gate/k8s_checks/devops_runtime.py:57, docs/TESTING.md:71]- Chosen: Name the digest and compare it offline. A bump fails at once and names the next action of the person.
- Rejected: Read the digest at run time. The result would not match the image that a person tested.
- Which digest does the command name?:
unclecode/crawl4ai:0.9.5@sha256:0b05666882bfb67f45d559a5b827839c54127b74aedd723f8ab338a3571b5fc9, the digest that the Deployment pins at this commit. [sources: k8s/devops/crawl4ai/deployment.yaml:50] - How does the command check the NetworkPolicy layer on its own?: The command starts a throwaway pod with the
crawl4ailabel in namespacedevopsthroughkubectl run, probes the private ClusterIP role and the metadata role from it, reports a block for each destination that fails, and deletes the pod. The pod uses a public image with a shell or HTTP client, and the offline test checks thekubectl runarguments, the delete and the destination list. (best practice) [sources: k8s/devops/crawl4ai/networkpolicy.yaml:14, tests/commands/k8s/test_k8s_network_policies.py:57, k8s/devops/crawl4ai/deployment.yaml:22]- Chosen: Throwaway pod with the
crawl4ailabel. The policy selects a pod by its label, and the check changes no workload. - Rejected:
kubectl execinto the running pod. The image has no shell, and the check would touch the running workload. - Rejected: An offline policy reader.
tests/commands/k8s/test_k8s_network_policies.pyalready reads the policy, and it does not test the running cluster.
- Chosen: Throwaway pod with the
- Which issue is the manifests issue that the body names?: feat(k8s): run Crawl4AI 0.9.5 in namespace devops #3884.
k8s/devops/crawl4ai/deployment.yaml:1andtests/invariants/test_k8s_crawl4ai.py:1cite it, andCHANGELOG.md:46records that feat(k8s): run Crawl4AI in the devops namespace #3977 closed it. The Deployment, Service and both policies are at this commit, so this item lists no dependency. [sources: k8s/devops/crawl4ai/deployment.yaml:1, tests/invariants/test_k8s_crawl4ai.py:1, CHANGELOG.md:46] - Which open, maintained tool covers the need?:
kubectl(Apache-2.0) covers the port-forward and the throwaway pod, and the project'sdevops_cli.http.entrycovers the requests. Neither knows the Crawl4AI route matrix, the refusal status or the report, and no open, maintained scanner tests a running Crawl4AI service. The change builds one command module and one gate check. (best practice) [sources: AGENTS.md:11, tests/gate/k8s_checks/devops_runtime.py:37, src/devops_cli/http/entry.py:52]- Chosen:
kubectlplus the project HTTP entry. They cover the cluster access and the requests; the route matrix, the refusal assertions and the report remain. - Rejected: A new SSRF scanner. No open, maintained scanner tests a running Crawl4AI service.
- Rejected: An offline NetworkPolicy checker. It reads the policy document only and does not test the running cluster.
- Chosen:
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(k8s)scope of the title gives the scope.It verifies security controls but does not block the deployment itself.It proves that SSRF and NetworkPolicy protections hold before any digest bump can silently remove them.It covers five routes, six targets, a NetworkPolicy pod check, skip logic, and a per-route result table.Both concern the Crawl4AI deployment in the devops namespace, but 3884 delivers the manifests and this candidate delivers a test that verifies the SSRF controls of that deployment.devops-cli-service commentedon Nov 7, 2026
Status set to Ready at a6fff84 (see proposed design in issue body).
Moved to new items: #4018, #4019.
dan-petty commentedon Nov 7, 2026
This item cannot be built as written. Rule 2 of AGENTS.md applies, so no code was written.
The item asks for a live-marked pytest test that reaches the cluster, reads the token from the keyring, and skips when the cluster is absent. It says other live tests do this. They do not. Evidence:
liveinpyproject.tomlmeans "live tests requiring the named local tool binaries".tests/conftest.pyuses it only to allow a local binary and to skip when that binary is missing. No test reaches a cluster Service.prevent_external_network_callsintests/conftest.pyrefuses every loopback connect that this test process does not own. Its docstring names akubectl port-forwardas a target it must not reach. An HTTP request through a port-forward fails in a test._DenyKeyring), so a test cannot readcrawl4ai_api_token.docs/TESTING.mdsays: "A test must not skip based on host state. A test that cannot run the same on every host is a contract case or adevops cirow", and "never a live service". ADR 0007 gives the reason.To pass these rules, the test would start a subprocess that the guard does not see, and read the keyring inside it. That is an escape from the hermetic floor, and rule 5 and the owner rule of 2026-10-20 forbid it.
Re-scope options (a person decides):
devops k8scommand, in the shape ofimage-pins,auditandrbac-audit. It starts the port-forward, reads the token through the keyring seam, sends the 25 requests and the no-token requests, starts the throwaway pod withkubectl run, and prints the table of route, target role, status and body length. Its tests use the process, HTTP and keyring fakes. The digest comparison is acheck_*function in thek8srow oftests/gate/. Cost estimate: about 400 lines, 70k tokens to write, one day.k8s/README.md, in the shape of "Go-live check", with the digest comparison as thek8srow check. Cost estimate: about 60 lines of text and 40 lines of check, 15k tokens.The owner already saw by hand on 2026-11-07:
POST /mdwithout a token returns 401, androadmap-serviceat its cluster DNS name returns "URL blocked (SSRF protection)". The full matrix is not yet run. I recommend option 1 if the check will run at each digest bump, and option 2 if it will run rarely. The follow-up issues #4018 and #4019 depend on the same shape.devops-cli-service commentedon Nov 7, 2026
Status set to Ready at d6c2297 (see proposed design in issue body).
devops-cli-service commentedon Nov 8, 2026
Released in v0.87.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.87.0
devops-cli-service commentedon Nov 8, 2026
Live since 2026-11-08 03:31 UTC