Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a218f0c
fix(security): keep credentials within runtime boundaries
Mavrick-F Nov 4, 2026
5d1df58
fix(security): bind approvals to exact execution scopes
Mavrick-F Nov 4, 2026
6ee147d
fix(security): preserve scoped execution across upstream workers
Mavrick-F Nov 5, 2026
1d8d39e
fix(security): enforce credential and execution boundaries
Mavrick-F Nov 5, 2026
cbbd62d
fix: close reviewed credential and execution gaps
Mavrick-F Nov 5, 2026
57d5d11
fix: retain queued request context and avoid repeated notices
Mavrick-F Nov 5, 2026
25ae2a1
fix(tiles): retain scoped service completion across main updates
Mavrick-F Nov 5, 2026
d1a5804
fix(data): preserve clean queries and complete HTTP test responses
Mavrick-F Nov 5, 2026
c4734e0
fix(plugins): preserve caller cancellation in pinned tools
Mavrick-F Nov 5, 2026
09bec19
Merge main and preserve admitted background reads
Mavrick-F Nov 5, 2026
1077814
fix(engine): align approval with command execution reach
Mavrick-F Nov 6, 2026
55a69f5
fix(security): retain project ownership through service discovery
Mavrick-F Nov 6, 2026
8387479
fix(test): isolate plugin publication and fetch spy scenarios
Mavrick-F Nov 6, 2026
76fabbe
fix(engine): report completed exports and template omissions
Mavrick-F Nov 6, 2026
448de3e
fix(engine): preserve owned execution with off-frame models
Mavrick-F Nov 6, 2026
a0197cc
fix(security): preserve opaque output and bound service choices
Mavrick-F Nov 6, 2026
d9e50d1
fix(security): complete output and deferred-work cleanup
Mavrick-F Nov 6, 2026
22526e0
fix(security): retain owned plugin download retries
Mavrick-F Nov 6, 2026
62f5d22
fix(security): preserve planned inputs and counted losses
Mavrick-F Nov 6, 2026
feb1a74
fix(security): preserve queue ownership and source reach
Mavrick-F Nov 6, 2026
ca78800
fix(security): preserve admission and metadata boundaries
Mavrick-F Nov 6, 2026
521ebd1
fix(security): keep credentials within runtime boundaries
Mavrick-F Nov 6, 2026
0c192f1
fix(security): bind approvals to exact execution scopes
Mavrick-F Nov 6, 2026
1ded5bd
fix(security): preserve exact sources and counted output losses
Mavrick-F Nov 7, 2026
aba5b1e
fix(security): preserve credential boundaries with raster sources
Mavrick-F Nov 7, 2026
d533b89
fix(security): close identifier and generated-output leaks
Mavrick-F Nov 7, 2026
a00df91
fix(security): redact credentials from returned errors
Mavrick-F Nov 7, 2026
f9c71eb
fix(security): retain deferred execution owners
Mavrick-F Nov 7, 2026
aafb06b
fix(tiles): avoid caching retired request failures
Mavrick-F Nov 7, 2026
203d0b7
Merge main after credential output boundaries
Mavrick-F Nov 7, 2026
fbbfc8d
Merge main and discard retired cache results
Mavrick-F Nov 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ Before picking work, read [ROADMAP.md](ROADMAP.md) (check Underway) and
- **Everything is a command**: a `CommandSpec` in `crates/engine/src/cmd/*.rs`. UI-only
commands (`ui.*`) live in `crates/ui-egui/src/lib.rs`. The ribbon, shortcuts, command search
and CLI dispatch by id. Commands never open dialogs.
- **Command ingress**: root `Session::run` is trusted native User dispatch. Assistant, MCP,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Root dispatch is trusted, and the embedding page reaches it. This rule says root Session::run is trusted native User dispatch. The browser embed path (apps/rustgis-web/src/web.rs, the Msg::Run arm around line 404) sends any ui.* id from a framing page through that same app.run, with no named scope. embed::runnable only checks the prefix. Commands such as ui.save, ui.saveAs, ui.addUrl, ui.importShapefile and ui.installPlugin are therefore reachable at User authority. SECURITY.md already calls this boundary "separate, unresolved", so it is disclosed rather than new. The PR title and description still say approvals are bound to exact scopes, which overstates coverage. Suggest stating the limit in the PR description, or narrowing the embed run set or moving it under a named scope. Confidence: high on the mechanism, medium on severity, because it depends on what each ui.* handler gates itself.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the current browser handler and embed::runnable: embedding-page ui.* RUN messages reach root dispatch, outside the named assistant/MCP/plugin/imported-item approval scopes. The PR description now states that limit explicitly and links the existing security boundary. This scope clarification preserves the tested source.

plugin, imported-item and continuation adapters carry their named opaque policy scope;
scopes inherit or narrow, and `with_scope` rejects nested ingress. Peer project text uses
`open_peer_text`. See [embedding-page limitations](SECURITY.md#embedding-page-command-boundary)
when changing web message handlers.
- **Ribbon placement** follows the
[ribbon guidelines](docs/contributing.md#ribbon-guidelines): the tab's purpose, one button per
destination, labels that say what happens, and what a ribbon pull request states.
Expand Down
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ including output from another session. This changes displayed output, not the st
requests or permission checks. RustGIS does not retain revoked secrets just to recognize them
in later output; review that output before sharing it.

## Embedding-page command boundary

The execution policy covers engine commands admitted through named assistant, MCP, plugin and
imported-item scopes. The authority of `ui.*` RUN messages from embedding pages remains a
separate, unresolved boundary; engine approval checks do not establish authorization for those
UI messages.

## What counts as a security problem

RustGIS makes promises about what untrusted plugins, files, agents and web pages can do. A way
Expand Down
20 changes: 17 additions & 3 deletions apps/rustgis-web/src/arcgis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ async fn sleep(ms: i32) -> Result<(), String> {
/// A request to the portal: a form POSTed, or a GET. Never redirected, never with the page's
/// cookies.
async fn request(url: &str, form: Option<&str>) -> Result<Vec<u8>, String> {
request_claimed(url, form, None).await
}

/// A renewal caused by a claimed download checks its owned predicate on first poll and send.
async fn request_claimed(url: &str, form: Option<&str>, still: Option<cache::Still>) -> Result<Vec<u8>, String> {
cache::check_still(&still)?;
let window = web_sys::window().ok_or("no window")?;
let init = web_sys::RequestInit::new();
init.set_redirect(web_sys::RequestRedirect::Error);
Expand All @@ -81,7 +87,9 @@ async fn request(url: &str, form: Option<&str>) -> Result<Vec<u8>, String> {
};
let timer = window.set_timeout_with_callback_and_timeout_and_arguments_0(stop.unchecked_ref(), REQUEST_MS).ok();
let read = async {
let resp: web_sys::Response = wasm_bindgen_futures::JsFuture::from(window.fetch_with_str_and_init(url, &init))
let promise =
crate::request::prepare_and_send(&still, || async { Ok(()) }, |()| window.fetch_with_str_and_init(url, &init)).await?;
let resp: web_sys::Response = wasm_bindgen_futures::JsFuture::from(promise)
.await
.map_err(|_| "couldn't reach the portal".to_string())?
.dyn_into()
Expand Down Expand Up @@ -177,7 +185,10 @@ async fn finish(flow: &arcgis_auth::WebSignIn, popup: &web_sys::Window) -> Resul

/// Renews the session covering `url` when its access token is about to expire (one renewal at a
/// time; the fetches meanwhile use the token, still valid for a minute).
pub async fn renew_if_due(url: &str) {
pub async fn renew_if_due(url: &str, still: Option<cache::Still>) {
if cache::check_still(&still).is_err() {
return;
}
if RENEWING.get() {
return;
}
Expand All @@ -191,6 +202,9 @@ pub async fn renew_if_due(url: &str) {
}
RENEWING.set(true);
let _renewing = Renewing;
let answer = request(&r.endpoint, Some(&r.body)).await;
let answer = request_claimed(&r.endpoint, Some(&r.body), still.clone()).await;
if cache::check_still(&still).is_err() {
return;
}
arcgis_auth::renewal_done(&r, answer.as_deref().map_err(String::clone));
}
38 changes: 31 additions & 7 deletions apps/rustgis-web/src/geolibre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ use wasm_bindgen::prelude::*;
// safeguards: the same trust as installing the npm package.
#[wasm_bindgen(inline_js = r#"
const BASE = "https://cdn.jsdelivr.net/npm/geolibre-wasm@1.8.0";
let loaded = null;
let ready = null;
function tools() {
async function tools(still = () => true) {
if (!still()) throw new Error("GeoLibre run cancelled before loading");
if (!loaded) {
loaded = import(`${BASE}/tools.mjs/+esm`);
loaded.catch(() => { loaded = null; });
}
const mod = await loaded;
if (!still()) throw new Error("GeoLibre run cancelled before initialization");
if (!ready) {
ready = (async () => {
const mod = await import(`${BASE}/tools.mjs/+esm`);
await mod.initTools(`${BASE}/geolibre-cli.wasm`);
return mod;
})();
// A failed download can be retried.
// A failed initialization can be retried without importing the module again.
ready.catch(() => { ready = null; });
}
return ready;
Expand Down Expand Up @@ -66,8 +73,10 @@ export async function geolibre_manifests() {
}
return text;
}
export async function geolibre_run(tool, argv, names, datas) {
const t = await tools();
export async function geolibre_run(tool, argv, names, datas, still) {
if (!still()) throw new Error("GeoLibre run cancelled before preparation");
const t = await tools(still);
if (!still()) throw new Error("GeoLibre run cancelled before starting");
const input = {};
for (let i = 0; i < names.length; i++) input[names[i]] = datas[i];
const r = await t.runTool(tool, { args: argv, input });
Expand All @@ -79,7 +88,13 @@ extern "C" {
#[wasm_bindgen(catch)]
async fn geolibre_manifests() -> Result<JsValue, JsValue>;
#[wasm_bindgen(catch)]
async fn geolibre_run(tool: &str, argv: js_sys::Array, names: js_sys::Array, datas: js_sys::Array) -> Result<JsValue, JsValue>;
async fn geolibre_run(
tool: &str,
argv: js_sys::Array,
names: js_sys::Array,
datas: js_sys::Array,
still: &js_sys::Function,
) -> Result<JsValue, JsValue>;
}

fn js_error(e: &JsValue) -> String {
Expand Down Expand Up @@ -114,10 +129,19 @@ pub fn manifests(slot: Slot<Result<String, String>>, ctx: egui::Context) {
/// Runs one tool and puts its new files and printed lines (or its error) in `slot`.
pub fn run(job: ExternalRun, slot: Slot<ExternalOutput>, ctx: egui::Context) {
wasm_bindgen_futures::spawn_local(async move {
if let Err(e) = job.can_start() {
if let Ok(mut out) = slot.lock() {
*out = Some(Err(e));
}
ctx.request_repaint();
return;
}
let argv: js_sys::Array = job.argv.iter().map(|a| JsValue::from_str(a)).collect();
let names: js_sys::Array = job.files.iter().map(|(n, _)| JsValue::from_str(n)).collect();
let datas: js_sys::Array = job.files.iter().map(|(_, b)| JsValue::from(js_sys::Uint8Array::from(b.as_slice()))).collect();
let r = match geolibre_run(&job.tool, argv, names, datas).await {
let still = job.still();
let check = wasm_bindgen::closure::Closure::<dyn Fn() -> bool>::new(move || still());
let r = match geolibre_run(&job.tool, argv, names, datas, check.as_ref().unchecked_ref()).await {
Err(e) => Err(js_error(&e)),
Ok(out) => {
let lines = strings(&get(&out, "stdout"));
Expand Down
2 changes: 2 additions & 0 deletions apps/rustgis-web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ mod embed;
mod geolibre;
#[cfg(target_arch = "wasm32")]
mod parts;
#[cfg(any(target_arch = "wasm32", test))]
mod request;
#[cfg(target_arch = "wasm32")]
mod web;

Expand Down
203 changes: 203 additions & 0 deletions apps/rustgis-web/src/request.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
//! The browser adapters' owned handoff, preparation and synchronous final-send boundary.
//! No synchronous diagnostic or request context is held while a future is suspended.

use rustgis_ui_egui::rustgis_engine::{data::diagnostics::Capture, render::rustgis_tiles::cache};
use std::future::Future;

/// Captures context at adapter invocation, before `spawn_local` can defer its first poll.
/// Completion re-enters it only synchronously, so callbacks can start follow-on requests.
pub(crate) fn handoff<T, F: Future<Output = Result<T, String>>>(
work: impl FnOnce(Capture, Option<cache::Still>) -> F,
done: impl FnOnce(Result<T, String>),
) -> impl Future<Output = ()> {
let capture = Capture::current();
let still = cache::current_still();
async move {
let result = match cache::check_still(&still) {
Ok(()) => work(capture.clone(), still.clone()).await,
Err(e) => Err(e),
};
let _diagnostics = capture.enter();
cache::with_optional_still(still, || done(result));
}
}

/// The actual adapters prepare lazily, including renewal awaits, then invoke their real fetch
/// synchronously after the final check. The sender must initiate I/O without another handoff.
pub(crate) async fn prepare_and_send<T, R, F: Future<Output = Result<T, String>>>(
still: &Option<cache::Still>,
prepare: impl FnOnce() -> F,
send: impl FnOnce(T) -> R,
) -> Result<R, String> {
cache::check_still(still)?;
let prepared = prepare().await?;
cache::check_still(still)?;
Ok(send(prepared))
}

#[cfg(test)]
mod tests {
use super::*;
use std::{
cell::{Cell, RefCell},
pin::Pin,
rc::Rc,
sync::{
Arc,
atomic::{AtomicBool, Ordering::SeqCst},
},
task::{Context, Poll, Waker},
};

fn poll<F: Future + ?Sized>(f: Pin<&mut F>) -> Poll<F::Output> {
f.poll(&mut Context::from_waker(Waker::noop()))
}

struct Held(Rc<Cell<bool>>);
impl Future for Held {
type Output = Result<(), String>;
fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
if self.0.get() { Poll::Ready(Ok(())) } else { Poll::Pending }
}
}

fn live() -> (Arc<AtomicBool>, cache::Still) {
let live = Arc::new(AtomicBool::new(true));
let flag = live.clone();
(live, Arc::new(move || flag.load(SeqCst)))
}

/// The installed GET/HEAD/POST handoff captures before scheduling, not on first poll.
#[test]
fn permission_transport_handoff_refuses_before_first_poll() {
let (live, still) = live();
let prepared = Cell::new(false);
let finished = Cell::new(false);
let mut f = Box::pin(cache::with_still(still, || {
handoff(
|_, _| async {
prepared.set(true);
Ok(())
},
|r| {
assert!(r.unwrap_err().contains("cancelled"));
finished.set(true);
},
)
}));
assert!(cache::current_still().is_none());
live.store(false, SeqCst);
assert!(poll(f.as_mut()).is_ready());
assert!(!prepared.get() && finished.get());
assert!(cache::current_still().is_none());
}

/// The same production preparation/send function backs GET, HEAD, POST and renewal fetch.
/// Unchanged account identity sends; replacement behind the same public URL stops a held send.
#[test]
fn permission_transport_preparation_await_refuses_final_send() {
use rustgis_ui_egui::rustgis_engine::render::rustgis_tiles::arcgis_auth as auth;
let url = "https://browser-identity.example.org/server/rest/services/A/MapServer";
auth::add_token(url, "synthetic-first").unwrap();
let identity = auth::account_identity_for(url).unwrap();
let still: cache::Still = Arc::new(move || identity.is_current());
let released = Rc::new(Cell::new(false));
let sends = Cell::new(0);
let finished = Cell::new(false);
let owned = Some(still.clone());
let mut clean = Box::pin(prepare_and_send(&owned, || async { Ok(()) }, |()| sends.set(sends.get() + 1)));
assert!(matches!(poll(clean.as_mut()), Poll::Ready(Ok(()))));
drop(clean);
assert_eq!(sends.get(), 1);
let mut f = Box::pin(cache::with_still(still, || {
handoff(
|_, still| {
let (released, sends) = (&released, &sends);
async move {
prepare_and_send(
&still,
|| async {
assert!(cache::current_still().is_none());
Held(released.clone()).await
},
|()| sends.set(sends.get() + 1),
)
.await
}
},
|r| {
assert!(r.unwrap_err().contains("cancelled"));
finished.set(true);
},
)
}));
assert!(poll(f.as_mut()).is_pending());
assert!(cache::current_still().is_none(), "no context crosses the await");
auth::add_token(url, "synthetic-replacement").unwrap();
released.set(true);
assert!(poll(f.as_mut()).is_ready());
assert_eq!(sends.get(), 1, "only the unchanged identity sent");
assert!(finished.get());
assert!(cache::current_still().is_none());
auth::sign_out(Some("https://browser-identity.example.org/server"));
}

/// A new service account binding cannot cross a browser preparation await under old consent.
#[test]
fn permission_transport_service_binding_refuses_after_preparation() {
use rustgis_ui_egui::rustgis_engine::render::rustgis_tiles::logins::{self, Method};
let url = "https://browser-service-identity.example";
let binding = logins::activate(url, "9150003/connection", Method::Header("X-Key".into()), "synthetic-browser", false).unwrap();
let identity = logins::account_identity(9_150_003).unwrap();
let still = Some(Arc::new(move || identity.is_current()) as cache::Still);
let released = Rc::new(Cell::new(false));
let sends = Cell::new(0);
let mut held = Box::pin(prepare_and_send(&still, || Held(released.clone()), |()| sends.set(sends.get() + 1)));
assert!(poll(held.as_mut()).is_pending());
let other = logins::activate(url, "91500030/connection", Method::Header("X-Key".into()), "synthetic-other", false).unwrap();
assert!(cache::check_still(&still).is_ok(), "another session preserves consent");
assert!(logins::deactivate(&binding));
let replacement = logins::activate(url, "9150003/connection", Method::Header("X-Key".into()), "synthetic-browser", false).unwrap();
released.set(true);
assert!(matches!(poll(held.as_mut()), Poll::Ready(Err(_))));
assert_eq!(sends.get(), 0);
assert!(cache::current_still().is_none(), "no context crosses the await");
assert!(logins::deactivate(&replacement));
assert!(logins::deactivate(&other));
}

/// A callback's follow-on adapter owns the same predicate after the callback returns.
#[test]
fn permission_transport_callback_follow_on_keeps_owned_context() {
let (live, still) = live();
let expected = still.clone();
let sends = Rc::new(Cell::new(0));
let finished = Rc::new(Cell::new(false));
type Pending = Pin<Box<dyn Future<Output = ()>>>;
let follow_on: RefCell<Option<Pending>> = RefCell::new(None);
let mut f = Box::pin(cache::with_still(still, || {
handoff(
|_, still| async move { prepare_and_send(&still, || async { Ok(()) }, |()| {}).await },
|r| {
r.unwrap();
assert!(Arc::ptr_eq(&cache::current_still().unwrap(), &expected));
let (sent, done) = (sends.clone(), finished.clone());
*follow_on.borrow_mut() = Some(Box::pin(handoff(
move |_, still| async move { prepare_and_send(&still, || async { Ok(()) }, |()| sent.set(sent.get() + 1)).await },
move |r| {
assert!(r.unwrap_err().contains("cancelled"));
done.set(true);
},
)));
},
)
}));
assert!(poll(f.as_mut()).is_ready());
assert!(cache::current_still().is_none());
live.store(false, SeqCst);
assert!(poll(follow_on.borrow_mut().as_mut().unwrap().as_mut()).is_ready());
assert_eq!(sends.get(), 0);
assert!(finished.get());
assert!(cache::current_still().is_none());
}
}
Loading
Loading