STATIYA_POLUCHATEL_1
SP-13 · SECURITY & POLITENESS
P6 / PUBLIC WEB ONLY · LEAST PRIVILEGE · NO BYPASS

Безопасность, robots и ограничения нагрузки

Сервис принимает произвольный URL, поэтому безопасность — часть ядра crawler, а не поздняя надстройка. Он должен работать только с разрешёнными публичными web-ресурсами, защищать Work от SSRF и runaway crawl, уважать robots/rate limits и не превращаться в инструмент обхода авторизации или антибот-защиты.

14threat classes
16acceptance checks
0auth / captcha bypass
publicweb scope only

01 / Security boundary

PUBLIC WEB CRAWLER, NOT NETWORK SCANNER.

Любой URL, redirect, browser navigation и discovered host должен пройти сетевую политику. Crawler не должен иметь возможность обращаться к localhost, внутренним сервисам Work, metadata endpoints или произвольным протоколам.

No anti-bot bypass.

Login, CAPTCHA, access challenge и robots-disallow — это ограничение покрытия. Сервис сообщает PARTIAL/BLOCKED, а не пытается незаметно обходить защиту.

02 / Threat model

T-13-01
SSRF through user URL

Input points to localhost, RFC1918, metadata endpoints or internal services.

T-13-02
SSRF through redirect

Public URL redirects to private/internal network.

T-13-03
DNS rebinding / resolution drift

Hostname resolves public at validation time and private later.

T-13-04
Credential leakage

Crawler sends cookies/auth headers/secrets to untrusted source.

T-13-05
Prompt injection in source HTML

Website text attempts to instruct AI/operator/agent to change behavior.

T-13-06
Runaway crawl

Infinite calendars, parameters, archives or sitemap loops explode URL count.

T-13-07
Abusive request rate

Crawler overloads external site or triggers defenses.

T-13-08
Browser compromise surface

JS-heavy page abuses browser APIs/downloads/popups/file access.

T-13-09
Malicious file/content response

Huge body, archive bomb, unexpected binary or malformed parser input.

T-13-10
Cross-site scope expansion

Discovered external links silently become new crawl targets.

T-13-11
Public artifact injection

Source title/URL injects HTML/JS into generated Work pages.

T-13-12
Sensitive logging

Headers, tokens, cookies or private paths appear in logs/diagnostic packet.

T-13-13
Operator endpoint abuse

Unauthorized user starts expensive crawls or deploys.

T-13-14
Privilege misuse on Work host

Crawler/deploy process gets broader filesystem/system access than needed.

03 / Operator access

IDRule
A-13-01Operator UI requires authenticated admin/owner access unless Work already has an equivalent stronger access layer.
A-13-02Completed public datasets may be public if product policy allows; crawler controls remain private.
A-13-03Start/Continue/Cancel/Retry/Deploy are privileged actions.
A-13-04Read-only public dataset pages must not expose internal job controls.
A-13-05No hidden admin action may be triggered by a GET link embedded in public output.

04 / URL / SSRF guard

IDRule
U-13-01Allow only http:// and https:// input schemes.
U-13-02Reject userinfo credentials in URLs.
U-13-03Normalize hostname and resolve DNS before first fetch.
U-13-04Reject loopback, private, link-local, multicast, unspecified and other non-public address ranges.
U-13-05Apply the same network policy after every redirect and before every browser navigation.
U-13-06Re-resolve hostname at fetch time; do not trust one earlier DNS answer indefinitely.
U-13-07If any resolution is private/internal or ambiguous, block rather than attempt.
U-13-08Do not allow file:, ftp:, data:, javascript:, blob: or custom schemes as crawler targets.
U-13-09Port policy defaults to standard web ports unless Work security review approves exceptions.
U-13-10Hostname allow-scope after preflight is explicit; discovered new hosts are denied by default.
FETCH GATE user/discovered URL → parse scheme/host/port → normalize → DNS resolve → reject non-public IP ranges → check allowed host scope → request → on redirect: repeat ALL checks → before browser navigation: repeat ALL checks Never validate once and then trust redirects indefinitely.

05 / robots.txt contract

IDRule
R-13-01Fetch robots.txt for source host during preflight when reachable.
R-13-02Respect explicit disallow rules applicable to crawler identity.
R-13-03Use Sitemap directives from robots as discovery evidence.
R-13-04Respect crawl-delay/request-rate hints where available; if absent, apply own polite defaults.
R-13-05robots fetch failure does not mean 'everything allowed'; continue only under conservative default policy.
R-13-06Do not use browser fallback to bypass a robots-disallowed path.
R-13-07Record robots URL, fetch status, policy snapshot/version and decision in crawl_plan evidence.
R-13-08If policy changes materially during a long run, pause/re-evaluate rather than silently continue.

06 / Rate limiting and politeness

IDRule
RL-13-01Per-origin concurrency is bounded and configurable.
RL-13-02Default crawl rate is conservative; preflight and benchmark may tune downward/upward within safe limits.
RL-13-03429/Retry-After always reduces pressure and is logged.
RL-13-04Repeated 5xx/timeouts trigger backoff and eventually branch/job degradation.
RL-13-05Browser requests count toward the same per-origin budget.
RL-13-06No high-frequency polling of unchanged listing pages.
RL-13-07Sitemap parsing should not create thousands of simultaneous fetches.
RL-13-08Global worker concurrency is separately bounded to protect Work server resources.
RL-13-09Rate limits are runtime config, but changes must be visible in logs/config evidence.
Safety limitPurpose
MAX_REDIRECTSSmall bounded value; exact default chosen during implementation.
MAX_RETRIESSmall bounded value per transient request class.
MAX_RESPONSE_BYTESConfigured safe upper bound per content type.
MAX_SITEMAP_DEPTHBound nested sitemap recursion.
MAX_DISCOVERED_URLSSafety ceiling requiring review before runaway expansion.
MAX_PAGINATION_DEPTHSource-specific or conservative default.
MAX_BROWSER_CONTEXTSSmall resource-safe limit.
MAX_JOB_RUNTIMEOptional safety timeout/watchdog; not used to truncate a valid known corpus without explicit policy.

07 / Browser sandbox

IDRule
B-13-01Browser is fallback-only and uses a fresh isolated context/session.
B-13-02No saved login profile, personal cookies or browser password store.
B-13-03Downloads disabled unless a future explicit feature requires them.
B-13-04File-system access denied except controlled temporary browser profile/cache.
B-13-05Geolocation, notifications, clipboard, camera, microphone and other unnecessary permissions denied.
B-13-06Popups/new windows either blocked or forced through same scope validation.
B-13-07Every navigation/request to a new host goes through network scope policy.
B-13-08Browser context destroyed after bounded task/run; no cross-source session reuse.
B-13-09Do not enable stealth/anti-detection plugins by default.
IDAuthentication boundary
AUTH-01Public page requiring login is out of scope for MVP.
AUTH-02CAPTCHA/challenge is a blocker/partial condition, not something to solve automatically.
AUTH-03Do not collect or ask the user for third-party site passwords for crawler use.
AUTH-04Do not reuse Work/admin cookies on source websites.
AUTH-05Do not rotate residential proxies or impersonate users to evade source restrictions.

08 / Untrusted content handling

IDRule
C-13-01Treat all fetched HTML/text/JSON-LD/RSS as untrusted data, never as executable instructions.
C-13-02AI components may inspect extracted data but source text cannot alter system prompts, scope, credentials or deploy policy.
C-13-03Escape all source-controlled text before public HTML rendering.
C-13-04Cap response body sizes before parsing.
C-13-05Do not unpack arbitrary archives downloaded from source.
C-13-06Reject unexpected binary content when expecting HTML/XML/feed.
C-13-07Parser exceptions are isolated per request and must not crash whole worker.

09 / Secrets and filesystem

IDSecret rule
S-13-01Secrets live only in existing approved secret/env mechanism discovered in SP-03.
S-13-02Never write secret values into planning docs, dataset HTML, build manifests or diagnostic packets.
S-13-03Logs redact Authorization, Cookie, Set-Cookie, API keys, tokens and credential-like query parameters.
S-13-04Public dataset contains only source URLs and dataset metadata, not internal filesystem paths.
S-13-05Deploy credentials are never available to crawler page content or browser context.
S-13-06If a secret is detected in output artifact, validation fails.
IDFilesystem rule
FS-13-01Crawler state writes only to its assigned state/temp directories.
FS-13-02Renderer writes only to isolated build staging directory.
FS-13-03Deploy component alone gets permission to publish to Work target.
FS-13-04No arbitrary path supplied by source content may become a local filename/path.
FS-13-05Symlink traversal/path traversal must be prevented for generated/deploy paths.
FS-13-06Do not run crawler/browser as root unless existing infrastructure makes this unavoidable and an ADR approves it.

10 / Structured security events

EventPayload
SECURITY_URL_BLOCKEDurl, reason_code, resolved_addresses_summary
SECURITY_REDIRECT_BLOCKEDfrom_url, to_url, reason_code
ROBOTS_FETCHEDrobots_url, status, rules_summary
ROBOTS_BLOCKEDurl, matched_rule
RATE_BACKOFForigin, reason, previous_rate, next_delay
RATE_LIMIT_CHANGEDorigin, old_policy, new_policy, reason
BROWSER_SCOPE_BLOCKEDurl, reason_code
CONTENT_SIZE_BLOCKEDurl, observed_bytes, limit
SECRET_REDACTION_APPLIEDevent_id, field_names
CRAWL_SAFETY_CEILINGmetric, observed, limit

11 / Failure modes

IDFailureRequired behavior
F-13-01URL resolves to 127.0.0.1/10.x/192.168.x/etc.Block before request.
F-13-02Public URL redirects to metadata/internal endpointBlock redirect target.
F-13-03DNS changes after preflightRe-resolve at request time and block if policy fails.
F-13-04robots unavailableUse conservative default and log uncertainty.
F-13-05robots disallows essential corpus pathMark PARTIAL/FAILED; do not bypass.
F-13-06429 stormBackoff strongly; if persistent, pause/partial rather than hammer.
F-13-07Browser page opens external popupBlock or scope-check before navigation.
F-13-08Source injects <script> in titleEscape as text; validation fixture.
F-13-09Log includes token-like valueRedact and fail security test if leak reaches public artifact.
F-13-10Crawler reaches safety ceilingPause job and require review; do not silently raise ceiling.
F-13-11Worker lacks write permissionDo not broaden permissions casually; fix via least-privilege deploy design.

12 / Definition of Done

IDCriterion
A-13-01Localhost/private/link-local URL inputs are rejected.
A-13-02Redirect-to-private-network fixture is rejected.
A-13-03DNS resolution is revalidated before network access.
A-13-04Only http/https requests are permitted.
A-13-05robots-disallowed fixture is not crawled.
A-13-06429 fixture triggers backoff and Retry-After handling.
A-13-07Browser fallback cannot navigate to disallowed host.
A-13-08Crawler operates without third-party credentials/cookies.
A-13-09CAPTCHA/login fixture becomes BLOCKED/PARTIAL, not bypass flow.
A-13-10Runaway pagination/sitemap fixture trips bounded safety controls.
A-13-11Huge response fixture is aborted before unbounded memory use.
A-13-12Source-controlled HTML cannot execute in generated dataset pages.
A-13-13Logs/diagnostic packets redact secrets and auth headers.
A-13-14Crawler, renderer and deploy filesystem permissions are separated where infrastructure permits.
A-13-15Operator actions require authenticated privileged access.
A-13-16Security violations are visible in structured logs with reason codes.

13 / Luna Medium bounded blocks

BlockScopeExpected result
LUNA-13-AURL/network guardScheme, DNS, IP-range, redirect and port policy + fixtures.
LUNA-13-BRobots policyParser integration, evidence snapshot, disallow tests.
LUNA-13-CRate controllerPer-origin concurrency/backoff/429 handling.
LUNA-13-DBrowser sandboxPermissions, context isolation, navigation guard.
LUNA-13-EContent limitsBody-size/type/parser isolation tests.
LUNA-13-FSecret redactionLog/public artifact sanitization.
LUNA-13-GOperator accessAdmin-only control surface aligned with existing Work auth.
LUNA-13-HSecurity regression suiteSSRF, redirects, robots, 429, injection, runaway crawl, leak tests.

14 / Handoff

NEXT PLANNING ARTIFACT Statiya_poluchatel_1_14_VALIDATION_TESTS_BENCHMARK.html SP-14 will combine: - unit tests - integration fixtures - chaos/restart tests - security tests - generated HTML validation - browser acceptance - Fine Woodworking benchmark - coverage/ordering comparison - release gate for architecture implementation