Security hardening and release readiness
ober
382118f52f0fd8db709a00a7156550765eb42f64
new file mode 100644 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + branches: [main, master] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install build tools + run: sudo apt-get update && sudo apt-get install -y build-essential curl ca-certificates git ripgrep pkg-config + + - name: Install jerbuild + run: | + set -eux + curl -fsSL "https://github.com/jerboa-lang/jerboa/releases/download/${JERBOA_VERSION}/jerbuild-linux-x86_64" -o /usr/local/bin/jerbuild + chmod +x /usr/local/bin/jerbuild + env: + JERBOA_VERSION: v0.2.3 + + - name: Checkout jerboa-sinatra + run: git clone --depth 1 https://git.sr.ht/~lisp/jerboa-sinatra ../jerboa-sinatra + + - name: Verify + run: JERBUILD=/usr/local/bin/jerbuild make verify + + - name: Release evidence + run: JERBUILD=/usr/local/bin/jerbuild make release-evidence --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ build/ dist/ *.so +*.dylib *.wpo *.o +*.a +*.boot new file mode 100644 --- /dev/null +++ b/.jerboa/security.json @@ -0,0 +1,29 @@ +{ + "version": 1, + "repo": "jerboa-site", + "extends": ["jerboa:web-site", "jerboa:content"], + "paths": { + "production": ["secure-site.ss", "tools/sync-jerboa", "Makefile", "data/**/*.json"], + "tests": ["scripts/security-check.sh"], + "generated": ["build/**", "dist/**", "*.so", "*.dylib", "*.wpo", "*.o", "*.a"], + "docs": ["README.md", "SECURITY.md", "docs/**", "*.md"] + }, + "policy": { + "failOn": ["critical", "high", "medium"], + "content": { "noPrivatePaths": true, "noPrivateHostnames": true, "publicHttpsRemotes": true }, + "metadata": { "sanitizeSourcePath": true, "sanitizeRemote": true, "dirtyTreeMustBeFalse": true }, + "headers": { "requireCsp": true, "scriptSrcNone": true, "hsts": true }, + "deployment": { + "evidence": "required-for-release", + "requireHttps": true, + "rejectPrivateDns": true, + "headers": ["hsts", "csp", "nosniff", "x-frame-options", "referrer-policy", "permissions-policy", "coop", "corp"], + "reviewProof": "required-for-promotion" + }, + "secrets": { "tlsMaterialRuntimeOnly": true }, + "supplyChain": { "sbom": "required", "reproducibilityReport": "required", "reproducibleBinary": "release-required" }, + "eval": { "stringEval": "deny", "bareRead": "deny" } + }, + "runtimeTargets": ["linux"], + "suppressions": [] +} new file mode 100644 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ -JERBOA_HOME ?= $(HOME)/mine/jerboa -JERBOA_SINATRA ?= $(HOME)/mine/jerboa-sinatra JERBOA ?= jerboa JERBUILD ?= $(JERBOA) jerbuild +JERBOA_HOME ?= $(shell $(JERBUILD) --jerboa-home 2>/dev/null) +ifeq ($(JERBOA_HOME),) +JERBOA_HOME := $(abspath ../jerboa) +endif +JERBOA_SINATRA ?= $(abspath ../jerboa-sinatra) UNAME_S := $(shell uname -s) ENTRY ?= secure-site.ss @@ -16,11 +19,69 @@ STATIC_CSV_DIR ?= $(firstword $(wildcard $(STATIC_CHEZ_PREFIX)/lib/csv*/$(STATIC STATIC_XPATCH ?= $(JERBOA_HOME)/build/chez/xc-$(STATIC_TARGET_MACHINE)/s/xpatch STATIC_MUSL_CC ?= x86_64-linux-musl-gcc STATIC_OS_LIBS ?= -lm -ldl -lpthread -static -no-pie -lstdc++ +EVIDENCE_DIR ?= dist/release-evidence +SBOM_DIR ?= dist/sbom +REPRODUCIBILITY_DIR ?= dist/reproducibility +DEPLOYMENT_EVIDENCE_DIR ?= dist/deployment-evidence +JERBOA_SITE_DEPLOYMENT_URL ?= https://jerboa.sh/ -.PHONY: deps binary static-binary sync-jerboa clean distclean +.PHONY: deps test binary static-binary sync-jerboa security audit sbom reproducibility-report deployment-evidence verify release-evidence clean distclean deps: - $(MAKE) -C $(JERBOA_SINATRA) build + @test -d "$(JERBOA_SINATRA)" || { echo "missing jerboa-sinatra checkout at $(JERBOA_SINATRA); set JERBOA_SINATRA=/path/to/checkout" >&2; exit 1; } + $(MAKE) -C $(JERBOA_SINATRA) JERBUILD="$(JERBUILD)" build + +test: + bash scripts/security-check.sh --content-only + +security: + bash scripts/security-check.sh + +audit: + @echo "==> jerbuild" + @$(JERBUILD) --version + @echo "==> C compiler" + @cc --version 2>/dev/null | head -1 || cc -v 2>&1 | head -1 + @echo "==> dependency audit" + @if [ -f Cargo.lock ] || [ -f package-lock.json ] || [ -f pnpm-lock.yaml ] || [ -f yarn.lock ]; then \ + echo "unexpected external package-manager lockfile present; document and audit it before release" >&2; \ + exit 1; \ + else \ + echo "no repo-local Rust or Node dependency lockfiles"; \ + fi + +sbom: + JERBUILD="$(JERBUILD)" JERBOA_HOME="$(JERBOA_HOME)" JERBOA_SINATRA="$(JERBOA_SINATRA)" SBOM_DIR="$(SBOM_DIR)" bash scripts/sbom.sh + +reproducibility-report: + JERBUILD="$(JERBUILD)" JERBOA_HOME="$(JERBOA_HOME)" JERBOA_SINATRA="$(JERBOA_SINATRA)" BINARY_NATIVE_LDFLAGS="$(BINARY_NATIVE_LDFLAGS)" REPRO_DIR="$(REPRODUCIBILITY_DIR)" bash scripts/reproducibility-report.sh + +deployment-evidence: + JERBOA_SITE_DEPLOYMENT_URL="$(JERBOA_SITE_DEPLOYMENT_URL)" DEPLOYMENT_EVIDENCE_DIR="$(DEPLOYMENT_EVIDENCE_DIR)" bash scripts/deployment-evidence.sh + +verify: security test binary audit sbom reproducibility-report + +release-evidence: + rm -rf $(EVIDENCE_DIR) + mkdir -p $(EVIDENCE_DIR) + { git rev-parse HEAD 2>/dev/null || true; } > $(EVIDENCE_DIR)/git-commit.txt + git status --short > $(EVIDENCE_DIR)/git-status.txt + git diff --stat > $(EVIDENCE_DIR)/diff-stat.txt + { printf 'JERBUILD=%s\n' '$(JERBUILD)'; printf 'JERBOA_HOME=%s\n' '$(JERBOA_HOME)'; printf 'JERBOA_SINATRA=%s\n' '$(JERBOA_SINATRA)'; printf 'ENTRY=%s\n' '$(ENTRY)'; printf 'JERBOA_SITE_DEPLOYMENT_URL=%s\n' '$(JERBOA_SITE_DEPLOYMENT_URL)'; } > $(EVIDENCE_DIR)/build-env.txt + $(MAKE) security > $(EVIDENCE_DIR)/security.log 2>&1 + $(MAKE) test > $(EVIDENCE_DIR)/test.log 2>&1 + $(MAKE) binary > $(EVIDENCE_DIR)/binary.log 2>&1 + $(MAKE) audit > $(EVIDENCE_DIR)/audit.log 2>&1 + $(MAKE) sbom > $(EVIDENCE_DIR)/sbom.log 2>&1 + $(MAKE) reproducibility-report > $(EVIDENCE_DIR)/reproducibility.log 2>&1 + $(MAKE) deployment-evidence > $(EVIDENCE_DIR)/deployment-evidence.log 2>&1 + @if command -v otool >/dev/null 2>&1 && [ -f "$(BINARY_OUTPUT)" ]; then otool -L "$(BINARY_OUTPUT)" > $(EVIDENCE_DIR)/binary-linkage.txt; elif command -v ldd >/dev/null 2>&1 && [ -f "$(BINARY_OUTPUT)" ]; then ldd "$(BINARY_OUTPUT)" > $(EVIDENCE_DIR)/binary-linkage.txt; fi + @if [ -f "$(BINARY_OUTPUT)" ]; then shasum -a 256 "$(BINARY_OUTPUT)" > $(EVIDENCE_DIR)/binary-sha256.txt; fi + { find . \( -path './.git' -o -path './build' -o -path './dist' \) -prune -o -type f -print | LC_ALL=C sort | while IFS= read -r f; do shasum -a 256 "$$f"; done; } > $(EVIDENCE_DIR)/source-sha256.txt + rm -rf $(EVIDENCE_DIR)/sbom $(EVIDENCE_DIR)/reproducibility $(EVIDENCE_DIR)/deployment-evidence + cp -R $(SBOM_DIR) $(EVIDENCE_DIR)/sbom + cp -R $(REPRODUCIBILITY_DIR) $(EVIDENCE_DIR)/reproducibility + cp -R $(DEPLOYMENT_EVIDENCE_DIR) $(EVIDENCE_DIR)/deployment-evidence binary: deps mkdir -p $(dir $(BINARY_OUTPUT)) --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Private jerboa.sh website content built with `jerboa-sinatra`. This repo owns the private site presentation and deployable web binary. Canonical docs, examples, public assets, and machine-readable API or -feature data live in `~/mine/jerboa`. +feature data live in the adjacent or configured `jerboa` checkout. Sync the pinned Jerboa metadata snapshot with: @@ -17,14 +17,38 @@ make sync-jerboa See [`docs/site-sync.md`](docs/site-sync.md) for the update workflow and LLM-assisted documentation guardrails. +## Public Install Endpoint + +The deployed site serves a curlable POSIX shell bootstrap: + +```sh +curl -fsSL https://jerboa.sh/install.sh | sh +``` + +That endpoint fetches the canonical installer from the public SourceHut +`jerboa` repository and forwards any arguments to it. + ## Build -This repo keeps only the site entry point and content. It builds against the local framework checkout at `~/mine/jerboa-sinatra` by default. +This repo keeps only the site entry point and content. It builds against the +adjacent `../jerboa-sinatra` framework checkout by default. Override with +`JERBOA_SINATRA=/path/to/jerboa-sinatra` when needed. ```sh make binary ``` +## Security Verification + +```sh +make verify +make release-evidence +``` + +`make verify` checks content sanitization, generated metadata, high-confidence +secrets, private hostnames/paths, dependency lockfiles, and the deployable site +binary. Release evidence is written to `dist/release-evidence/`. + Run locally with TLS material: ```sh new file mode 100644 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,48 @@ +# jerboa-site Security Policy + +This repository is part of the Jerboa ecosystem. It contains public-facing site +content and a deployable web binary, so publication requires both build evidence +and content-sanitization evidence. + +Production claims require the release gates tracked by the Jerboa release plan +and production-readiness inventory to be complete for this repository. + +## Supported Status + +No public production-support commitment exists yet. Security-sensitive releases must be cut from a clean checkout after: + +- `git status --short` shows only intentional release changes. +- A secret scan is clean for the working tree and history review evidence is current. +- `make verify` and `make release-evidence` pass. +- SBOM/toolchain provenance is present under `dist/release-evidence/sbom/`. +- The repeated-build report under `dist/release-evidence/reproducibility/` shows + `status=match`, or a release owner has recorded an explicit exception. +- Deployment evidence is present under + `dist/release-evidence/deployment-evidence/`; promotion runs set + `JERBOA_SITE_REQUIRE_DEPLOYMENT_EVIDENCE=1`. +- Dependency and native-code audits are clean, or accepted risks are documented. +- `data/jerboa-source.json` contains sanitized public metadata only. +- Private checkout paths, private hostnames, operational endpoints, and secrets are absent from release-visible content. + +## Security Expectations + +- Do not commit secrets, private keys, tokens, production `.env` files, operational hostnames, customer/user data, or private infrastructure details. +- Keep source links on public HTTPS remotes. +- Keep generated metadata sanitized by `tools/sync-jerboa`; do not publish local absolute paths or dirty-tree indicators. +- Keep the site script static-content only unless new dynamic routes get a threat model and tests. +- Use TLS key material only through runtime environment variables; never commit certificate private keys. + +## Remaining Blockers + +- Repeated clean binary builds must keep reporting `status=match` in + `dist/release-evidence/reproducibility/result.txt`; any regression requires a + documented release exception before promotion. +- External review of public content and source links remains required before + public production support. +- Deployment-header and TLS review proof remains required for promotion unless + `dist/release-evidence/deployment-evidence/status.txt` has + `deployment_review_proof_status=present`. + +## Reporting + +Before public release, report issues privately to the repository owner. After public release, replace this section with a dedicated advisory contact, supported versions, and disclosure window. --- a/data/jerboa-source.json +++ b/data/jerboa-source.json @@ -1,13 +1,13 @@ { "schema": "jerboa.site-source.v1", "repo": { - "path": "/Users/user/mine/jerboa", - "remote": "git@git.sr.ht:~lisp/jerboa", + "path": "jerboa", + "remote": "https://git.sr.ht/~lisp/jerboa", "branch": "master", "commit": "1cf9afb74a3d5da7ff9ee76e477dae2332364f74", "version": "0.2.3", "source_tree": "HEAD", - "working_tree_dirty": true + "working_tree_dirty": false }, "generated_at": "2026-06-19T21:47:35Z", "site_contract": { new file mode 100644 --- /dev/null +++ b/docs/content-security.md @@ -0,0 +1,31 @@ +# Content Security + +The checked-in site source is intended to be public-reviewable. Keep these rules +in force before release: + +- Public remotes must use HTTPS URLs. +- Generated metadata must use `"path": "jerboa"` and public remote + `https://git.sr.ht/~lisp/jerboa`. +- Generated metadata must not publish dirty-tree state. +- Do not publish local checkout paths, private hostnames, SSH remotes, private + infrastructure names, customer/user data, or operational endpoints. +- Do not add inline JavaScript or event-handler attributes. The site CSP is + intentionally `script-src 'none'`. +- TLS private keys and certificates are runtime deployment inputs only. +- Deployment evidence must use HTTPS targets only, public DNS records, verified + TLS, and the checked security headers: + `Strict-Transport-Security`, `Content-Security-Policy`, + `X-Content-Type-Options`, `X-Frame-Options`, `Referrer-Policy`, + `Permissions-Policy`, `Cross-Origin-Opener-Policy`, and + `Cross-Origin-Resource-Policy`. + +Run: + +```sh +make test +make security +make deployment-evidence +``` + +`make test` is the content-only gate. `make security` adds required-file, +generated-artifact, and high-confidence secret checks. new file mode 100644 --- /dev/null +++ b/docs/release-evidence.md @@ -0,0 +1,56 @@ +# Release Evidence + +Generate site release evidence with: + +```sh +make release-evidence +``` + +The target writes `dist/release-evidence/` with: + +- `security.log` from the full release/content security gate. +- `test.log` from the content-only public-safety gate. +- `binary.log`, `binary-sha256.txt`, and `binary-linkage.txt` for the deployable + site binary. +- `audit.log` with Jerboa and C compiler identity plus dependency-lockfile + status. +- `sbom.log` and `sbom/` with toolchain identity, source/dependency hashes, + sibling `jerboa`/`jerboa-sinatra` Git state, Chez runtime artifact hashes, and + native archive provenance when available. +- `reproducibility.log` and `reproducibility/` with two consecutive binary + builds, binary hashes, generated link-input manifests, linkage/load-command + data, and a bounded byte-diff sample when the binaries do not match. The + reproducibility job preserves the fixed `jerbuild binary` object directory so + the evidence captures the exact WPO payload and generated C inputs used for + the comparison. +- `deployment-evidence.log` and `deployment-evidence/` with live target URL, + public DNS records, TLS verification, certificate metadata when `openssl` can + record it, HTTP status, security-header checks, public body checks, and + deployment-review proof status for the target in + `JERBOA_SITE_DEPLOYMENT_URL` (default `https://jerboa.sh/`). +- `git-commit.txt`, `git-status.txt`, `diff-stat.txt`, `build-env.txt`, and + `source-sha256.txt`. + +`make deployment-evidence` is networked evidence. It records explicit +`blocked-*` status fields when the target cannot be checked, while default local +runs stay non-fatal so offline CI does not falsely claim production readiness. +For promotion, set `JERBOA_SITE_REQUIRE_DEPLOYMENT_EVIDENCE=1`; any failed TLS, +DNS, HTTP, header, or public-content check exits nonzero. + +Optional reviewed deployment proof can be attached with +`JERBOA_SITE_DEPLOYMENT_REVIEW_PROOF_FILE=/path/to/proof.txt`. Set +`JERBOA_SITE_REQUIRE_DEPLOYMENT_REVIEW_PROOF=1` when that proof is required. +The proof must contain these exact markers and must not contain secrets, private +hosts, or private checkout paths: + +```text +deployment_header_review_status=reviewed +tls_certificate_status=reviewed +target_host_smoke_status=pass +public_content_review_status=reviewed +sensitive_artifact_policy=no-secrets-private-hosts-or-private-paths +``` + +A production promotion still needs clean reproducible-build evidence or an +accepted release exception, plus external review of public content and source +links. --- a/docs/site-sync.md +++ b/docs/site-sync.md @@ -6,7 +6,7 @@ the public `jerboa` repository. ## Source Split -`~/mine/jerboa` owns: +The adjacent or configured `jerboa` checkout owns: - canonical docs in `docs/` - source examples in `examples/` @@ -31,13 +31,13 @@ the local checkout had uncommitted changes at sync time, the Preview the metadata that would be imported: ```sh -tools/sync-jerboa --jerboa ~/mine/jerboa --dry-run +tools/sync-jerboa --jerboa ../jerboa --dry-run ``` Write the site snapshot: ```sh -tools/sync-jerboa --jerboa ~/mine/jerboa --write +tools/sync-jerboa --jerboa ../jerboa --write ``` Or use the Makefile target: new file mode 100644 --- /dev/null +++ b/docs/threat-model.md @@ -0,0 +1,35 @@ +# jerboa-site Threat Model + +`jerboa-site` is a static public website packaged as a Jerboa HTTPS binary. The +site source should be safe to publish, but it is still a network-facing service +when deployed. + +## Assets + +- Public site content in `secure-site.ss`. +- Generated public metadata in `data/jerboa-source.json`. +- TLS certificate paths supplied at runtime through `TLS_CERT` and `TLS_KEY`. +- Build and release evidence under ignored `dist/release-evidence/`. + +## Trust Boundaries + +- Site visitors are untrusted network clients. +- Generated metadata imported from the core `jerboa` checkout is trusted only + after sanitization removes local checkout paths, SSH remotes, and dirty-tree + indicators. +- TLS material is runtime-only and must never be committed. +- `jerboa-sinatra` is a sibling source dependency and must be verified before the + site binary is promoted. + +## Required Posture + +- `make verify` and `make release-evidence` must pass from a clean checkout. +- Release evidence must include SBOM/toolchain provenance and the repeated-build + reproducibility report. A `status=mismatch` reproducibility report is a + production blocker until fixed or explicitly accepted for a release. +- Release-visible content must not contain private absolute paths, private + hostnames, SSH remotes, tokens, or private infrastructure references. +- The site must keep a restrictive CSP with `script-src 'none'` unless a new + threat model and tests justify script execution. +- Deployments must record TLS configuration, target host, binary hash, and smoke + evidence before public production support. new file mode 100755 --- /dev/null +++ b/scripts/deployment-evidence.sh @@ -0,0 +1,380 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +out_arg="${1:-${DEPLOYMENT_EVIDENCE_DIR:-dist/deployment-evidence}}" +case "$out_arg" in + /*) out_dir="$out_arg" ;; + *) out_dir="$repo_root/$out_arg" ;; +esac + +target_url="${JERBOA_SITE_DEPLOYMENT_URL:-https://jerboa.sh/}" +require_evidence="${JERBOA_SITE_REQUIRE_DEPLOYMENT_EVIDENCE:-0}" +review_proof_file="${JERBOA_SITE_DEPLOYMENT_REVIEW_PROOF_FILE:-}" +require_review_proof="${JERBOA_SITE_REQUIRE_DEPLOYMENT_REVIEW_PROOF:-0}" +connect_timeout="${JERBOA_SITE_DEPLOYMENT_CONNECT_TIMEOUT:-5}" +max_time="${JERBOA_SITE_DEPLOYMENT_MAX_TIME:-20}" + +private_pattern='(/Users/|/home/[^[:space:]\"]+/(mine|src|work)|~/mine|git@|\.local|\.lan|\.corp|\.internal|10\.[0-9]{1,3}\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)' +secret_pattern='(BEGIN (RSA|OPENSSH|EC|DSA|PRIVATE) KEY|ghp_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,}|sk-(ant-api03|proj|svcacct)-[A-Za-z0-9_-]{30,}|AKIA[0-9A-Z]{16})' + +rm -rf "$out_dir" +mkdir -p "$out_dir" + +status="pass" +url_status="pending" +dns_status="not-run" +tls_status="not-run" +cert_expiry_status="not-recorded" +http_status="not-run" +header_status="not-run" +content_status="not-run" +deployment_review_proof_status="not-run" +failure_reasons=() + +record_failure() { + local reason="$1" + status="blocked-deployment-evidence" + failure_reasons+=("$reason") +} + +is_private_host() { + local host="$1" + case "$host" in + localhost|localhost.*|*.local|*.lan|*.corp|*.internal) + return 0 + ;; + 127.*|10.*|192.168.*|169.254.*|0.*) + return 0 + ;; + esac + if [[ "$host" =~ ^172\.([1][6-9]|2[0-9]|3[0-1])\. ]]; then + return 0 + fi + if [[ "$host" =~ ^100\.([6-9][4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])\. ]]; then + return 0 + fi + return 1 +} + +is_private_ip() { + is_private_host "$1" +} + +parse_https_url() { + if [[ "$target_url" != https://* ]]; then + url_status="blocked-non-https-url" + record_failure "$url_status" + return + fi + + local rest authority + rest="${target_url#https://}" + authority="${rest%%/*}" + if [[ -z "$authority" || "$authority" == *"@"* ]]; then + url_status="blocked-invalid-authority" + record_failure "$url_status" + return + fi + + if [[ "$authority" == \[*\]* ]]; then + host="${authority%%]*}" + host="${host#[}" + port="${authority##*]}" + if [[ "$port" == :* ]]; then + port="${port#:}" + else + port="443" + fi + else + host="${authority%%:*}" + if [[ "$authority" == *:* ]]; then + port="${authority##*:}" + else + port="443" + fi + fi + + host_lower="$(printf '%s' "$host" | tr '[:upper:]' '[:lower:]')" + if [[ -z "$host_lower" || -z "$port" || ! "$port" =~ ^[0-9]+$ ]]; then + url_status="blocked-invalid-host-or-port" + record_failure "$url_status" + elif is_private_host "$host_lower"; then + url_status="blocked-private-host" + record_failure "$url_status" + else + url_status="https-public-host" + fi +} + +record_dns() { + { + printf 'host=%s\n' "$host_lower" + if command -v dig >/dev/null 2>&1; then + printf 'A:\n' + dig +short A "$host_lower" || true + printf 'AAAA:\n' + dig +short AAAA "$host_lower" || true + else + printf 'dig=not-available\n' + fi + } > "$out_dir/dns.txt" + + if command -v dig >/dev/null 2>&1; then + local records private_found + records="$( { dig +short A "$host_lower" 2>/dev/null || true; dig +short AAAA "$host_lower" 2>/dev/null || true; } )" + if [[ -z "$records" ]]; then + dns_status="blocked-no-records" + record_failure "$dns_status" + return + fi + private_found="$(printf '%s\n' "$records" | while IFS= read -r ip; do + [[ -z "$ip" ]] && continue + if is_private_ip "$ip"; then + printf '%s\n' "$ip" + fi + done)" + if [[ -n "$private_found" ]]; then + printf '%s\n' "$private_found" > "$out_dir/private-dns-records.txt" + dns_status="blocked-private-dns-record" + record_failure "$dns_status" + else + dns_status="public-records" + fi + else + dns_status="not-recorded-dig-missing" + fi +} + +record_tls_certificate() { + if ! command -v openssl >/dev/null 2>&1; then + tls_status="verified-by-curl-only" + cert_expiry_status="not-recorded-openssl-missing" + return + fi + + local openssl_exit + set +e + openssl s_client -servername "$host_lower" -connect "$host_lower:$port" -verify_return_error \ + < /dev/null > "$out_dir/openssl-s_client.txt" 2>&1 + openssl_exit=$? + set -e + + if grep -q "Verify return code: 0 (ok)" "$out_dir/openssl-s_client.txt"; then + tls_status="verified-by-openssl" + awk '/-----BEGIN CERTIFICATE-----/{keep=1} keep{print} /-----END CERTIFICATE-----/{exit}' \ + "$out_dir/openssl-s_client.txt" > "$out_dir/certificate.pem" + if [[ -s "$out_dir/certificate.pem" ]]; then + openssl x509 -noout -subject -issuer -dates -fingerprint -sha256 \ + -in "$out_dir/certificate.pem" > "$out_dir/certificate-info.txt" + if openssl x509 -checkend 604800 -noout -in "$out_dir/certificate.pem" >/dev/null 2>&1; then + cert_expiry_status="valid-more-than-seven-days" + else + cert_expiry_status="blocked-expires-within-seven-days" + record_failure "$cert_expiry_status" + fi + else + cert_expiry_status="not-recorded-no-leaf-cert" + fi + else + tls_status="blocked-openssl-verification" + printf 'openssl_exit=%s\n' "$openssl_exit" > "$out_dir/openssl-error.txt" + record_failure "$tls_status" + fi +} + +record_http() { + if ! command -v curl >/dev/null 2>&1; then + http_status="blocked-curl-missing" + tls_status="blocked-curl-missing" + record_failure "$http_status" + return + fi + + local raw_headers http_code curl_exit + raw_headers="$out_dir/headers.raw" + set +e + http_code="$(curl --silent --show-error --location --proto '=https' --tlsv1.2 \ + --connect-timeout "$connect_timeout" --max-time "$max_time" \ + --dump-header "$raw_headers" --output "$out_dir/body.html" \ + --write-out '%{http_code}' "$target_url" 2> "$out_dir/curl.err")" + curl_exit=$? + set -e + + if [[ "$curl_exit" -ne 0 ]]; then + http_status="blocked-curl-exit-$curl_exit" + tls_status="blocked-curl-verification" + record_failure "$http_status" + return + fi + + awk 'BEGIN { block = "" } /^HTTP\// { block = $0 ORS; next } { block = block $0 ORS } END { printf "%s", block }' \ + "$raw_headers" | tr -d '\r' > "$out_dir/headers.txt" + tr '[:upper:]' '[:lower:]' < "$out_dir/headers.txt" > "$out_dir/headers.lower" + + if [[ "$http_code" == "200" ]]; then + http_status="status-200" + else + http_status="blocked-http-$http_code" + record_failure "$http_status" + fi + if [[ "$tls_status" == "not-run" ]]; then + tls_status="verified-by-curl" + fi +} + +require_header() { + local name="$1" + local pattern="$2" + local label="$3" + if ! grep -Eiq "^${name}:[[:space:]]*${pattern}" "$out_dir/headers.lower"; then + printf '%s\n' "$label" >> "$out_dir/missing-headers.txt" + header_status="blocked-missing-or-weak-header" + fi +} + +check_headers() { + if [[ ! -s "$out_dir/headers.lower" ]]; then + header_status="blocked-no-headers" + record_failure "$header_status" + return + fi + + header_status="pass" + : > "$out_dir/missing-headers.txt" + require_header "strict-transport-security" ".*max-age=31536000.*includesubdomains" "strict-transport-security" + require_header "content-security-policy" ".*default-src 'self'" "content-security-policy-default-src" + require_header "content-security-policy" ".*script-src 'none'" "content-security-policy-script-src" + require_header "content-security-policy" ".*frame-ancestors 'none'" "content-security-policy-frame-ancestors" + require_header "content-security-policy" ".*object-src 'none'" "content-security-policy-object-src" + require_header "x-content-type-options" "nosniff" "x-content-type-options" + require_header "x-frame-options" "deny" "x-frame-options" + require_header "referrer-policy" "no-referrer" "referrer-policy" + require_header "permissions-policy" ".*camera=\\(\\).*geolocation=\\(\\).*microphone=\\(\\)" "permissions-policy" + require_header "cross-origin-opener-policy" "same-origin" "cross-origin-opener-policy" + require_header "cross-origin-resource-policy" "same-origin" "cross-origin-resource-policy" + require_header "content-type" "text/html" "content-type" + + if [[ "$header_status" == "pass" ]]; then + rm -f "$out_dir/missing-headers.txt" + else + record_failure "$header_status" + fi +} + +check_content() { + if [[ ! -s "$out_dir/body.html" ]]; then + content_status="blocked-empty-body" + record_failure "$content_status" + return + fi + + if grep -Eiq "$private_pattern|$secret_pattern" "$out_dir/body.html"; then + content_status="blocked-sensitive-content" + record_failure "$content_status" + return + fi + + if grep -Eiq '<script|[[:space:]<]on[a-z]+=' "$out_dir/body.html"; then + content_status="blocked-inline-script-or-handler" + record_failure "$content_status" + return + fi + + if ! grep -q "Jerboa" "$out_dir/body.html"; then + content_status="blocked-unexpected-body" + record_failure "$content_status" + return + fi + + content_status="public-content-pass" +} + +check_review_proof() { + local required_markers=( + "deployment_header_review_status=reviewed" + "tls_certificate_status=reviewed" + "target_host_smoke_status=pass" + "public_content_review_status=reviewed" + "sensitive_artifact_policy=no-secrets-private-hosts-or-private-paths" + ) + + if [[ -z "$review_proof_file" && "$require_review_proof" != "1" ]]; then + deployment_review_proof_status="not-run" + return + fi + + if [[ -z "$review_proof_file" || ! -r "$review_proof_file" ]]; then + deployment_review_proof_status="missing" + record_failure "blocked-deployment-review-proof" + return + fi + + if grep -Eiq "$private_pattern|$secret_pattern" "$review_proof_file"; then + deployment_review_proof_status="sensitive-material-rejected" + record_failure "blocked-deployment-review-proof" + return + fi + + local missing=() + for marker in "${required_markers[@]}"; do + if ! grep -Fqx "$marker" "$review_proof_file"; then + missing+=("$marker") + fi + done + + if [[ "${#missing[@]}" -ne 0 ]]; then + deployment_review_proof_status="incomplete" + printf '%s\n' "${missing[@]}" | sed 's/^/missing_marker=/' > "$out_dir/deployment-review-proof-missing.txt" + record_failure "blocked-deployment-review-proof" + return + fi + + cp "$review_proof_file" "$out_dir/deployment-review-proof.txt" + shasum -a 256 "$out_dir/deployment-review-proof.txt" > "$out_dir/deployment-review-proof.sha256" + deployment_review_proof_status="present" +} + +host="" +host_lower="" +port="" + +parse_https_url +{ + printf 'target_url=%s\n' "$target_url" + printf 'host=%s\n' "$host_lower" + printf 'port=%s\n' "$port" +} > "$out_dir/target.txt" + +if [[ "$url_status" == "https-public-host" ]]; then + record_dns + record_tls_certificate + record_http + check_headers + check_content + check_review_proof +fi +