Skip to content

fix: send session_end notification before wipe/close (#6)#14

Open
rafabd1 wants to merge 1 commit into
mainfrom
fix/issue-6-wipe-session-notification
Open

fix: send session_end notification before wipe/close (#6)#14
rafabd1 wants to merge 1 commit into
mainfrom
fix/issue-6-wipe-session-notification

Conversation

@rafabd1
Copy link
Copy Markdown
Owner

@rafabd1 rafabd1 commented Mar 14, 2026

Fix: Send session_end notification before wipe/close

Closes #6

Problem

When a user triggers panic_wipe() or close_session(), the local session is shut down but the peer receives no protocol-level notification. This creates an asymmetric state where one side thinks the session is active while the other has already destroyed it.

Solution

  • Added a new "end" wire message type to the protocol
  • Both close_session and do_panic_wipe now send a {"t":"end"} frame to the peer before shutting down the stream writer
  • The receive_loop / handle_incoming_message now recognizes "end" messages and:
    • Clears the local session
    • Emits session_closed with reason: "peer_ended" to the frontend
    • Breaks the receive loop cleanly

Security considerations

  • The "end" message is sent as a best-effort signal — if the I2P tunnel is already broken, the send may fail silently, which is acceptable since the stream will eventually error out on the peer side
  • No sensitive data is included in the "end" frame

This PR was generated with Oz.

- Add 'end' wire message type sent to peer before shutdown
- Handle incoming 'end' messages in receive_loop to cleanly close session
- Both close_session and panic_wipe now notify peer before destroying state
- Peer receives session_closed event with reason='peer_ended'

Co-Authored-By: Oz <oz-agent@warp.dev>
@rafabd1 rafabd1 force-pushed the fix/issue-6-wipe-session-notification branch from a798b96 to 4f6f82b Compare March 29, 2026 01:50
@rafabd1
Copy link
Copy Markdown
Owner Author

rafabd1 commented May 5, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f6f82b5ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if let Some(mut s) = sess.take() {
// Notify peer that session is ending before destroying everything
let end_msg = serde_json::to_vec(&SessionEnd { t: "end".into() }).unwrap_or_default();
let _ = write_framed(&mut s.stream_writer, &end_msg).await;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid awaiting peer notify in panic wipe path

do_panic_wipe now awaits write_framed before clearing session/identity state, so a stalled or backpressured socket can delay the wipe indefinitely (the write path uses write_all/flush and has no timeout). In the panic-wipe scenario this is a correctness and safety regression: local sensitive state is kept alive longer specifically when the peer/network is unhealthy. Make the end notification non-blocking (e.g., bounded timeout or spawned best-effort task) and perform local wipe immediately.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRITICAL: Wipe clears peer session without notification

1 participant