Repository navigation
fix(security): bind approvals to exact execution scopes #1461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 5d1df58
fix(security): bind approvals to exact execution scopes
Mavrick-F 6ee147d
fix(security): preserve scoped execution across upstream workers
Mavrick-F 1d8d39e
fix(security): enforce credential and execution boundaries
Mavrick-F cbbd62d
fix: close reviewed credential and execution gaps
Mavrick-F 57d5d11
fix: retain queued request context and avoid repeated notices
Mavrick-F 25ae2a1
fix(tiles): retain scoped service completion across main updates
Mavrick-F d1a5804
fix(data): preserve clean queries and complete HTTP test responses
Mavrick-F c4734e0
fix(plugins): preserve caller cancellation in pinned tools
Mavrick-F 09bec19
Merge main and preserve admitted background reads
Mavrick-F 1077814
fix(engine): align approval with command execution reach
Mavrick-F 55a69f5
fix(security): retain project ownership through service discovery
Mavrick-F 8387479
fix(test): isolate plugin publication and fetch spy scenarios
Mavrick-F 76fabbe
fix(engine): report completed exports and template omissions
Mavrick-F 448de3e
fix(engine): preserve owned execution with off-frame models
Mavrick-F a0197cc
fix(security): preserve opaque output and bound service choices
Mavrick-F d9e50d1
fix(security): complete output and deferred-work cleanup
Mavrick-F 22526e0
fix(security): retain owned plugin download retries
Mavrick-F 62f5d22
fix(security): preserve planned inputs and counted losses
Mavrick-F feb1a74
fix(security): preserve queue ownership and source reach
Mavrick-F ca78800
fix(security): preserve admission and metadata boundaries
Mavrick-F 521ebd1
fix(security): keep credentials within runtime boundaries
Mavrick-F 0c192f1
fix(security): bind approvals to exact execution scopes
Mavrick-F 1ded5bd
fix(security): preserve exact sources and counted output losses
Mavrick-F aba5b1e
fix(security): preserve credential boundaries with raster sources
Mavrick-F d533b89
fix(security): close identifier and generated-output leaks
Mavrick-F a00df91
fix(security): redact credentials from returned errors
Mavrick-F f9c71eb
fix(security): retain deferred execution owners
Mavrick-F aafb06b
fix(tiles): avoid caching retired request failures
Mavrick-F 203d0b7
Merge main after credential output boundaries
Mavrick-F fbbfc8d
Merge main and discard retired cache results
Mavrick-F File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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::runis trusted native User dispatch. The browser embed path (apps/rustgis-web/src/web.rs, theMsg::Runarm around line 404) sends anyui.*id from a framing page through that sameapp.run, with no named scope.embed::runnableonly checks the prefix. Commands such asui.save,ui.saveAs,ui.addUrl,ui.importShapefileandui.installPluginare 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 embedrunset 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.There was a problem hiding this comment.
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-pageui.*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.