feat: replace plaintext key storage with OWS encrypted vault#57
Open
kevarifin14 wants to merge 1 commit intoPolymarket:mainfrom
Open
feat: replace plaintext key storage with OWS encrypted vault#57kevarifin14 wants to merge 1 commit intoPolymarket:mainfrom
kevarifin14 wants to merge 1 commit intoPolymarket:mainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| if let Some(ref ows_id) = config.ows_id { | ||
| let key = crate::ows::export_private_key(ows_id) | ||
| .context("Failed to decrypt key from OWS vault")?; | ||
| return Ok((Some((*key).clone()), KeySource::ConfigFile)); |
There was a problem hiding this comment.
Zeroizing protection defeated by cloning key into plain String
Medium Severity
resolve_key calls export_private_key which returns Zeroizing<String>, but then does (*key).clone() to produce a plain String. This unprotected copy is returned to all callers (auth.rs, wallet.rs) and won't be zeroed when dropped, contradicting the PR's goal that keys are "wiped from memory" after use.
185072f to
74f88bb
Compare
Private keys are no longer stored in the clear in config.json. All key material is managed by the Open Wallet Standard (OWS) encrypted vault (AES-256-GCM, scrypt KDF). - Add `ows_id` field to Config — immutable UUID referencing OWS wallet - Add `src/ows.rs` — OWS backend via `ows-lib` crate (3 tests) - `wallet create` generates keys directly in OWS vault - `wallet import` imports keys into OWS vault - `resolve_key` decrypts from OWS vault when `ows_id` is present - Legacy plaintext `private_key` field still read as fallback
74f88bb to
59092d6
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Summary
config.jsonwith OWS (Open Wallet Standard) encrypted vault (AES-256-GCM, scrypt KDF)ows-lib = "1.0.0"andows-core = "1.0.0"Rust crates directlyChanges
Cargo.tomlows-lib,ows-core,hex,zeroizedependenciessrc/ows.rssrc/config.rsows_idfield to Config.save_walletstores in OWS.resolve_keydecrypts from OWS.src/commands/wallet.rswallet creategenerates keys in OWS vault.wallet importimports into OWS.src/main.rsowsmoduleBefore / After
Before (
~/.config/polymarket/config.json):{ "private_key": "0xdeadbeef...", "chain_id": 137, "signature_type": "proxy" }After:
{ "chain_id": 137, "signature_type": "proxy", "ows_id": "c8ad47a9-296b-4107-be74-9155695739a3" }Test plan
cargo checkpassescargo test— 49/49 tests passcargo clippy— cleanNote
Medium Risk
Changes key management and config persistence, including automatic migration and runtime decryption for signing; mistakes could lock users out of wallets or break auth flows.
Overview
Migrates wallet key storage from plaintext
config.jsonto an OWS encrypted vault, persisting only anows_idin config and decrypting keys on-demand viaresolve_key.Updates
wallet create/wallet importto create/import keys into OWS, adds startup migration of legacy plaintext configs, and introduces a newowsmodule (with tests) plus new crypto/OWS-related dependencies inCargo.toml/Cargo.lock.Written by Cursor Bugbot for commit 59092d6. This will update automatically on new commits. Configure here.