Add opencode-handoff-p2p skill (Collaboration & Project Management) - #4
Add opencode-handoff-p2p skill (Collaboration & Project Management)#4Eldorado-ling wants to merge 2 commits into
Conversation
Transfers OpenCode session share URLs peer-to-peer between machines or collaborators via personal GitHub private inbox repositories. Features: - 5-tier verification pipeline (filename / trust / content / commit attribution / GPG signature) - Transactional fetch-before-delete (data preservation on fetch failure) - Prompt-injection-safe Chinese trust boundary preamble - Reference Python implementation (verify_inbox.py) for deterministic cross-shell behavior Main repo: https://github.com/Eldorado-ling/opencode-handoff-p2p Category: Collaboration & Project Management
There was a problem hiding this comment.
Code Review
This pull request introduces the opencode-handoff-p2p skill, which enables peer-to-peer transfer of OpenCode session share URLs via private GitHub inbox repositories, supported by a reference Python verification script. The review feedback identifies a critical security vulnerability in the verification script where checking only the original adding commit allows attribution and signature bypasses on modified files; updating this to check the last modifying commit is recommended. Additionally, the feedback suggests allowing the SSH protocol in git clone configurations to prevent failures for users with SSH-default GitHub CLI setups.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| def get_add_sha(clone: Path, filepath: str) -> Optional[str]: | ||
| rc, out, _ = run([ | ||
| "git", "-C", str(clone), | ||
| "log", "--diff-filter=A", "--format=%H", "--", filepath, | ||
| ]) | ||
| if rc != 0: | ||
| return None | ||
| lines = [l for l in out.decode("utf-8", "replace").splitlines() if l] | ||
| return lines[0] if lines else None |
There was a problem hiding this comment.
Critical Security Vulnerability: Attribution & Signature Bypass via File Modification
Using git log --diff-filter=A retrieves the commit that originally added the file. If a collaborator (or an attacker with write access) modifies an existing handoff file rather than creating a new one, get_add_sha will still return the original commit SHA.
Consequently:
- Tier 4 (author/committer check) and Tier 5 (GPG signature check) will run against the original, trusted commit.
- The modified, untrusted content (containing a potentially malicious URL) currently at
HEADwill be fetched and executed/displayed.
This completely bypasses the signature and attribution verification.
Solution
Query the last commit that modified the file instead of the adding commit. This ensures that the commit responsible for the current file content is the one being verified.
Rename this function to get_last_commit_sha and use git log -1:
| def get_add_sha(clone: Path, filepath: str) -> Optional[str]: | |
| rc, out, _ = run([ | |
| "git", "-C", str(clone), | |
| "log", "--diff-filter=A", "--format=%H", "--", filepath, | |
| ]) | |
| if rc != 0: | |
| return None | |
| lines = [l for l in out.decode("utf-8", "replace").splitlines() if l] | |
| return lines[0] if lines else None | |
| def get_last_commit_sha(clone: Path, filepath: str) -> Optional[str]: | |
| rc, out, _ = run([ | |
| "git", "-C", str(clone), | |
| "log", "-1", "--format=%H", "--", filepath, | |
| ]) | |
| if rc != 0: | |
| return None | |
| lines = [l for l in out.decode("utf-8", "replace").splitlines() if l] | |
| return lines[0] if lines else None |
| return result | ||
| result["url"] = url_or_reason | ||
|
|
||
| sha = get_add_sha(clone, filename) |
| gh repo clone "$ME/$REPO_NAME" <path> -- \ | ||
| -c core.symlinks=false \ | ||
| -c protocol.file.allow=never \ | ||
| -c protocol.allow=never \ | ||
| -c protocol.https.allow=always \ | ||
| -c submodule.recurse=false |
There was a problem hiding this comment.
Usability Issue: SSH Protocol Blocked for GitHub CLI Clones
Many developers configure the GitHub CLI (gh) to use SSH by default (gh config set git_protocol ssh).
By setting protocol.allow=never and only allowing protocol.https.allow=always, any SSH-based clone attempt will fail with fatal: transport 'ssh' not allowed.
To support both HTTPS and SSH configurations seamlessly while maintaining hardening against other protocols (like file://), you should also explicitly allow the ssh protocol.
| gh repo clone "$ME/$REPO_NAME" <path> -- \ | |
| -c core.symlinks=false \ | |
| -c protocol.file.allow=never \ | |
| -c protocol.allow=never \ | |
| -c protocol.https.allow=always \ | |
| -c submodule.recurse=false | |
| gh repo clone "$ME/$REPO_NAME" <path> -- \ | |
| -c core.symlinks=false \ | |
| -c protocol.file.allow=never \ | |
| -c protocol.allow=never \ | |
| -c protocol.https.allow=always \ | |
| -c protocol.ssh.allow=always \ | |
| -c submodule.recurse=false |
| git -C <clone-path> config --local core.symlinks false | ||
| git -C <clone-path> config --local submodule.recurse false | ||
| git -C <clone-path> config --local protocol.allow never | ||
| git -C <clone-path> config --local protocol.https.allow always | ||
| git -C <clone-path> config --local protocol.file.allow never |
There was a problem hiding this comment.
Explicitly allow the ssh protocol in the local git configuration to support SSH-based clones.
| git -C <clone-path> config --local core.symlinks false | |
| git -C <clone-path> config --local submodule.recurse false | |
| git -C <clone-path> config --local protocol.allow never | |
| git -C <clone-path> config --local protocol.https.allow always | |
| git -C <clone-path> config --local protocol.file.allow never | |
| git -C <clone-path> config --local core.symlinks false | |
| git -C <clone-path> config --local submodule.recurse false | |
| git -C <clone-path> config --local protocol.allow never | |
| git -C <clone-path> config --local protocol.https.allow always | |
| git -C <clone-path> config --local protocol.ssh.allow always | |
| git -C <clone-path> config --local protocol.file.allow never |
| gh repo clone "<recipient>/$REPO_NAME" "$tmpdir" -- \ | ||
| -c core.symlinks=false -c protocol.file.allow=never \ | ||
| -c protocol.allow=never -c protocol.https.allow=always \ | ||
| -c submodule.recurse=false |
There was a problem hiding this comment.
Allow the ssh protocol during recipient repository cloning to support SSH-based GitHub CLI configurations.
| gh repo clone "<recipient>/$REPO_NAME" "$tmpdir" -- \ | |
| -c core.symlinks=false -c protocol.file.allow=never \ | |
| -c protocol.allow=never -c protocol.https.allow=always \ | |
| -c submodule.recurse=false | |
| gh repo clone "<recipient>/$REPO_NAME" "$tmpdir" -- \ | |
| -c core.symlinks=false -c protocol.file.allow=never \ | |
| -c protocol.allow=never -c protocol.https.allow=always \ | |
| -c protocol.ssh.allow=always \ | |
| -c submodule.recurse=false |
Fixes both issues identified by the Gemini Code Assist bot: 1. CRITICAL: Tier 4/5 identity bypass via post-add modification verify_inbox.py: rename get_add_sha to get_last_modifying_sha, switch from 'git log --diff-filter=A' to 'git log -1' so we verify the commit that produced the current blob (not the original add). 2. Clone fails for SSH-default gh users SKILL.md: add -c protocol.ssh.allow=always alongside the existing protocol.https.allow=always in all clone hardening blocks. Main repo updated to v1.0.1: https://github.com/Eldorado-ling/opencode-handoff-p2p/releases/tag/v1.0.1
|
@gemini-code-assist Thanks for the review! Both issues are fixed in this update: ✅ Tier 4/5 identity bypass (CRITICAL)Renamed Tested locally with simulated attack: alice signs+pushes a legitimate handoff → mallory modifies it locally → verify script correctly flags Tier 4 failure with ✅ SSH protocol allowAdded Main repo updated to v1.0.1https://github.com/Eldorado-ling/opencode-handoff-p2p/releases/tag/v1.0.1 — signed commit (verified), signed tag. Same fixes also applied to the bundled (shared + P2P) variant at https://github.com/Eldorado-ling/opencode-handoff-skill v1.0.1 (not part of this PR). |
|
Thanks for the update, @Eldorado-ling. The changes look solid. Switching to |
What this PR adds
A new skill: opencode-handoff-p2p under "Collaboration & Project Management".
Real use case
OpenCode users frequently want to transfer the current session's context to:
The current pattern is
/share→ copy URL → paste into WeChat/Slack/email → recipient opens it → manually relays context to their agent. High friction, easily lost, URLs scattered across chat history.This skill replaces that with: user says "send to bob" → agent automatically verifies, signs, and pushes to bob's private GitHub inbox repo. Bob's next session: "check inbox" → agent pulls, runs 5-tier verification, fetches transcript, injects into current session.
What's included
SKILL.md— the protocol the agent reads (~440 lines)verify_inbox.py— reference verification script (~290 lines Python)README.md— pointer to full deployment guide in main repoTested with OpenCode
Production-tested end-to-end with DeepSeek V4 Pro on Windows + Git Bash. Specifically validated:
verified: truefor properly signed commits)\r?\nterminator for cross-platform robustness)Safety
require_signed_commits: trueMain repo
https://github.com/Eldorado-ling/opencode-handoff-p2p
Includes full INSTALL.md (minimal + hardened deployment paths), USAGE.md (daily workflow + 11 error scenarios), 3-round security audit results, MIT license.
Comparison with combined variant
There's also https://github.com/Eldorado-ling/opencode-handoff-skill which bundles shared-central-repo mode + P2P. This PR submits only the P2P-only variant which has the smallest attack surface and simplest config — recommended for individual users and small (≤5 people) trust groups.