Restrict operator HTTP to loopback

This commit is contained in:
Meta Vens 2026-08-18 21:44:53 +02:00
commit f7c9db29be
8 changed files with 54 additions and 7 deletions

View file

@ -1,6 +1,6 @@
use axum::{
Json, Router,
extract::{Path, State},
extract::{ConnectInfo, Path, State},
http::{HeaderMap, HeaderValue, StatusCode, header},
response::{IntoResponse, Redirect, Response},
routing::{get, post},
@ -292,7 +292,11 @@ async fn main() -> anyhow::Result<()> {
.parse()?;
let listener = tokio::net::TcpListener::bind(address).await?;
tracing::info!(%address, "GhostlightDungeon listening");
axum::serve(listener, app).await?;
axum::serve(
listener,
app.into_make_service_with_connect_info::<SocketAddr>(),
)
.await?;
Ok(())
}
@ -1770,10 +1774,14 @@ async fn export_canon_candidates_markdown(
}
async fn set_provider_parallelism(
ConnectInfo(peer): ConnectInfo<SocketAddr>,
headers: HeaderMap,
State(state): State<AppState>,
Json(request): Json<ProviderParallelismRequest>,
) -> Response {
if !operator_peer_allowed(peer) {
return StatusCode::FORBIDDEN.into_response();
}
let session = match authenticated_session(&headers, &state).await {
Some(value) => value,
None => return StatusCode::UNAUTHORIZED.into_response(),
@ -1810,7 +1818,14 @@ async fn set_provider_parallelism(
}
}
async fn operator_inspector(headers: HeaderMap, State(state): State<AppState>) -> Response {
async fn operator_inspector(
ConnectInfo(peer): ConnectInfo<SocketAddr>,
headers: HeaderMap,
State(state): State<AppState>,
) -> Response {
if !operator_peer_allowed(peer) {
return StatusCode::FORBIDDEN.into_response();
}
let session = match authenticated_session(&headers, &state).await {
Some(value) => value,
None => return StatusCode::UNAUTHORIZED.into_response(),
@ -1836,6 +1851,10 @@ async fn operator_inspector(headers: HeaderMap, State(state): State<AppState>) -
}
}
fn operator_peer_allowed(peer: SocketAddr) -> bool {
peer.ip().is_loopback()
}
async fn process_due_ticks(
state: &AppState,
runtime: &CampaignRuntime,
@ -2404,6 +2423,16 @@ mod tests {
));
}
#[test]
fn operator_http_boundary_is_loopback_only() {
assert!(operator_peer_allowed("127.0.0.1:8831".parse().unwrap()));
assert!(operator_peer_allowed("[::1]:8831".parse().unwrap()));
assert!(!operator_peer_allowed(
"192.168.178.158:55000".parse().unwrap()
));
assert!(!operator_peer_allowed("10.77.0.4:55000".parse().unwrap()));
}
#[test]
fn npc_reactions_receive_player_speech_not_private_effect_scaffolding() {
let command = WorldCommand::Speak {

View file

@ -828,6 +828,13 @@ rejects `ReplaceResolutionPins`. Fission candidates are restricted to active
population leaves at the player's canonical current location; remote population
names remain in the operator surface.
The operator surface now has a real HTTP boundary. Axum carries the direct TCP
peer address into the operator inspector and provider-parallelism handlers;
only loopback plus a valid campaign session is admitted. LAN/WireGuard tester
peers receive `403`, and the browser hides the operator panel away from
loopback. Do not replace this with trusted forwarded headers unless a named
reverse proxy becomes the actual connection owner.
## Warnings
- Keep persistent state small. Git history and artifacts own chronology.

View file

@ -335,6 +335,14 @@ It likewise exposes only the number of operator pins and local active
population leaves eligible for a fission preview. Pin bodies, remote population
names, and `ReplaceResolutionPins` remain outside the player boundary.
HTTP operator inspection and provider-parallelism mutation require both an
authenticated campaign session and an actual loopback TCP peer. The daemon uses
Axum connection metadata from its direct listener; forwarded address headers do
not grant authority. LAN and WireGuard peers receive `403` before spoiler state
or controls are read. The browser operator panel is present only when loaded
from `127.0.0.1`, `localhost`, or `::1`; this mirrors the server boundary and is
not itself treated as security.
Global strategic context has a separate non-causal lane. Two stable broad Vault
queries run alongside local retrieval, and a Flash extraction stage proposes at
most 32 remote institution names with one short durable mandate each. Local code

View file

@ -103,4 +103,5 @@
{"ts":"2026-08-18T19:33:00Z","type":"deployment","status":"ok","branch":"codex/ghostlight-dungeon-mvp","note":"Starfire activated immutable release c4a3d6f38bc6f95a94404a52cbb3401f24a89aab with executable SHA-256 7a6fe39503cf62b9e6a496cda4e92f1d552f6c7f79a91e2b69e41c9d729ada61 and rollback 5e198dfa872a710d31e581dcf2cd0851bef01966. Typed health, manifest, active junction, PID 12164, four persisted campaigns, and DeepSeek readiness agree. Publication did not rotate or consume invitations."}
{"ts":"2026-08-18T19:37:00Z","type":"security","status":"ok","branch":"codex/ghostlight-dungeon-mvp","note":"Restored resolution-control ownership at the player membrane. Players retain active_cell_budget control; ReplaceResolutionPins is rejected by the player HTTP boundary, the browser pin editor is deleted, and player projection exposes only pin_count rather than operator pin subjects/reasons. Player fission targets now contain only active population leaves at the canonical current location. Regressions prove remote pin bodies and a secret remote population name are absent while a local population remains available."}
{"ts":"2026-08-18T19:41:00Z","type":"deployment","status":"ok","branch":"codex/ghostlight-dungeon-mvp","note":"Starfire activated immutable release c509d2a95bb7683b10561abad7d4857aeab6277d with executable SHA-256 041b85ed31e58f73cbd2e75d054cac32a5ad06a5944e1e129d39df5fb5e8df8e and rollback c4a3d6f38bc6f95a94404a52cbb3401f24a89aab. Typed health, manifest, active junction, PID 27396, four persisted campaigns, DeepSeek readiness, and served asset index-CXe_foJ-.js agree. Publication did not rotate or consume invitations."}
{"ts":"2026-08-18T19:45:00Z","type":"security","status":"ok","branch":"codex/ghostlight-dungeon-mvp","note":"Established a real operator HTTP boundary: the inspector and provider-parallelism mutation now require an authenticated session from an actual loopback TCP peer supplied by Axum ConnectInfo. LAN and WireGuard peers are denied before private state access; forwarded headers grant nothing. The browser operator panel is hidden unless loaded from loopback, mirroring but not replacing server authority. IPv4/IPv6 loopback and LAN/WireGuard negative unit cases plus the production web build pass."}
{"ts":"2026-08-18T18:52:00Z","type":"verification","status":"ok","branch":"codex/ghostlight-dungeon-mvp","note":"Exact release 7916ab04936ba962720cfbf4af1b83f9aa8d8b24 made every selected named member exception a mandatory Projector perspective owner, closing the seam where aggregation could erase an actionable individual before Persona choice. The strict provider-backed budget-one golden placed 24 rivals in one arena, attributed migration to member:mira-venn, moved her between depth-two population lineages, produced nine sustained material consequences including seven typed outcomes across six other background subjects, preserved her delta and the player, and automatically promoted the same Mira on return with zero rejected pulses. Witness: F:\\GameCult\\GhostlightDungeon\\acceptance\\gestalt-dynamics-7916ab0-strict\\result.json."}

File diff suppressed because one or more lines are too long

4
web/dist/index.html vendored
View file

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>GhostlightDungeon</title> <script type="module" crossorigin src="/assets/index-CXe_foJ-.js"></script>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>GhostlightDungeon</title> <script type="module" crossorigin src="/assets/index-lsoqjre5.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-B7Qh0xAi.css">
</head>
<body><header><p class="eyebrow">STARFIRE / PRIVATE VERSE</p><h1>GhostlightDungeon</h1><p id="status" role="status" aria-live="polite">Reading the world…</p></header><main>
@ -12,5 +12,5 @@
<section id="campaign-lab" hidden><h2>Campaign laboratory</h2><div id="campaign-list"></div>
<form id="resolution-form"><label for="active-cell-budget">Active Persona-cell budget: <output id="active-cell-budget-value">8</output></label><input id="active-cell-budget" name="active_cell_budget" type="range" min="1" max="32" value="8"><p id="resolution-status"></p><button type="submit">Apply at safe boundary</button></form>
<form id="fission-form"><p class="form-heading">Approval-gated population fission</p><label for="fission-parent">Population</label><select name="parent_gestalt_id" id="fission-parent" required></select><label for="fission-axis">Partition axis</label><select id="fission-axis" name="partition_axis"><option value="geography">Geography</option><option value="ideology">Ideology</option><option value="authority">Authority</option><option value="economy_role">Economic role</option><option value="species_body">Species/body</option><option value="information">Information</option></select><label for="fission-values">Named cuts, comma separated</label><input id="fission-values" name="requested_partition_values" required><label for="fission-reason">Why does this population need canonical leaves?</label><input id="fission-reason" name="reason" required><button type="submit">Compile fission preview</button></form>
<form id="fork-form"><label for="fork-name">Fork name</label><input id="fork-name" name="name" required><button type="submit">Fork selected campaign</button></form><form id="reset-form"><label for="reset-name">Reset branch name</label><input id="reset-name" name="name" required><button type="submit">Reset from selected branch seed</button></form><a href="/api/campaigns/export" download>Export selected CultCache .cc</a> <a href="/api/campaigns/canon-candidates.md" download>Export canon candidates Markdown</a><details><summary>Operator inspector</summary><form id="provider-parallelism-form"><label for="provider-parallelism">Provider request parallelism: <output id="provider-parallelism-value">8</output></label><input id="provider-parallelism" type="range" min="1" max="32" value="8"><button type="submit">Apply operator limit</button></form><button type="button" id="load-operator">Load private state and receipts</button><div id="operator-output"></div></details></section>
<form id="fork-form"><label for="fork-name">Fork name</label><input id="fork-name" name="name" required><button type="submit">Fork selected campaign</button></form><form id="reset-form"><label for="reset-name">Reset branch name</label><input id="reset-name" name="name" required><button type="submit">Reset from selected branch seed</button></form><a href="/api/campaigns/export" download>Export selected CultCache .cc</a> <a href="/api/campaigns/canon-candidates.md" download>Export canon candidates Markdown</a><details id="operator-lab" hidden><summary>Operator inspector</summary><form id="provider-parallelism-form"><label for="provider-parallelism">Provider request parallelism: <output id="provider-parallelism-value">8</output></label><input id="provider-parallelism" type="range" min="1" max="32" value="8"><button type="submit">Apply operator limit</button></form><button type="button" id="load-operator">Load private state and receipts</button><div id="operator-output"></div></details></section>
</main></body></html>

View file

@ -10,5 +10,5 @@
<section id="campaign-lab" hidden><h2>Campaign laboratory</h2><div id="campaign-list"></div>
<form id="resolution-form"><label for="active-cell-budget">Active Persona-cell budget: <output id="active-cell-budget-value">8</output></label><input id="active-cell-budget" name="active_cell_budget" type="range" min="1" max="32" value="8"><p id="resolution-status"></p><button type="submit">Apply at safe boundary</button></form>
<form id="fission-form"><p class="form-heading">Approval-gated population fission</p><label for="fission-parent">Population</label><select name="parent_gestalt_id" id="fission-parent" required></select><label for="fission-axis">Partition axis</label><select id="fission-axis" name="partition_axis"><option value="geography">Geography</option><option value="ideology">Ideology</option><option value="authority">Authority</option><option value="economy_role">Economic role</option><option value="species_body">Species/body</option><option value="information">Information</option></select><label for="fission-values">Named cuts, comma separated</label><input id="fission-values" name="requested_partition_values" required><label for="fission-reason">Why does this population need canonical leaves?</label><input id="fission-reason" name="reason" required><button type="submit">Compile fission preview</button></form>
<form id="fork-form"><label for="fork-name">Fork name</label><input id="fork-name" name="name" required><button type="submit">Fork selected campaign</button></form><form id="reset-form"><label for="reset-name">Reset branch name</label><input id="reset-name" name="name" required><button type="submit">Reset from selected branch seed</button></form><a href="/api/campaigns/export" download>Export selected CultCache .cc</a> <a href="/api/campaigns/canon-candidates.md" download>Export canon candidates Markdown</a><details><summary>Operator inspector</summary><form id="provider-parallelism-form"><label for="provider-parallelism">Provider request parallelism: <output id="provider-parallelism-value">8</output></label><input id="provider-parallelism" type="range" min="1" max="32" value="8"><button type="submit">Apply operator limit</button></form><button type="button" id="load-operator">Load private state and receipts</button><div id="operator-output"></div></details></section>
<form id="fork-form"><label for="fork-name">Fork name</label><input id="fork-name" name="name" required><button type="submit">Fork selected campaign</button></form><form id="reset-form"><label for="reset-name">Reset branch name</label><input id="reset-name" name="name" required><button type="submit">Reset from selected branch seed</button></form><a href="/api/campaigns/export" download>Export selected CultCache .cc</a> <a href="/api/campaigns/canon-candidates.md" download>Export canon candidates Markdown</a><details id="operator-lab" hidden><summary>Operator inspector</summary><form id="provider-parallelism-form"><label for="provider-parallelism">Provider request parallelism: <output id="provider-parallelism-value">8</output></label><input id="provider-parallelism" type="range" min="1" max="32" value="8"><button type="submit">Apply operator limit</button></form><button type="button" id="load-operator">Load private state and receipts</button><div id="operator-output"></div></details></section>
</main><script type="module" src="/src/main.ts"></script></body></html>

View file

@ -11,6 +11,8 @@ const destinationForm = document.querySelector<HTMLFormElement>("#destination-fo
const compilerResults = document.querySelector<HTMLElement>("#compiler-results")!;
const campaignLab = document.querySelector<HTMLElement>("#campaign-lab")!;
const campaignList = document.querySelector<HTMLElement>("#campaign-list")!;
const operatorLab = document.querySelector<HTMLDetailsElement>("#operator-lab")!;
operatorLab.hidden = !["127.0.0.1", "localhost", "::1"].includes(window.location.hostname);
let revision = 0;
let playerActorId = "";
let resolutionEpoch = 0;