{"id":"XE-13234","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"361","source_url":"https://github.com/xeprotocol/xe/issues/361","reporter_id":1121,"title":"Wallet Seed File Permission Vulnerability","area":"sdk-docs-web","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:02.412288+00:00","updated_at":"2026-11-20T00:07:00.829499+00:00","source_created_at":"2026-11-11T07:56:21+00:00","told_at":"2026-11-20T00:04:26+00:00","status_changed_at":"2026-11-20T00:04:22.072117+00:00","url":"https://bounty.xe.network/XE-13234","body":"Wallet seed files created by `./xe wallet create` are saved with default file permissions, potentially making them world-readable on multi-user systems. No automatic `chmod 600` enforcement or permission warnings are displayed, leading to private key exposure risk.\n\n**Severity:** Medium (2,500 XE)  \n**Type:** Local Key Exposure / Insecure File Permissions  \n**File:** CLI wallet commands  \n**Commit:** 89a542e\n## Vulnerability Details\n\n### Current Behavior\n\nWhen a wallet is created, the seed file `~/.xe/wallet.seed` is written with **default umask permissions**, which on most systems is `644` (owner read/write, group read, world read).\n\n```bash\n$ ./xe wallet create\nWallet created!\n  Address:    fb736676a3dd5fa81c16bf7abfd1b3290efc07b9cfd3df2d141f1a63d5bde3a8\n  File:       /root/.xe/wallet.seed\n\n$ ls -la ~/.xe/wallet.seed\n-rw-r--r-- 1 user user 128 Nov 11 07:00 /root/.xe/wallet.seed\n# ⚠️ World-readable! Any local user can steal private key\n```\n\n### Root Cause\n\n- No explicit permission setting in wallet creation code\n- No verification of existing file permissions on load\n- No warning displayed to user about insecure permissions\n- Relies on system umask (varies by environment)\n## Attack Vector\n\n### Scenario 1: Shared Server Environment\n\n1. **User creates wallet** on shared VPS/cloud instance\n2. **Seed file created** with default permissions (644)\n3. **Another user** on same system runs `cat /home/victim/.xe/wallet.seed`\n4. **Attacker extracts private key** from hex seed\n5. **Funds stolen** from victim's wallet\n\n### Scenario 2: Compromised Backup\n\n1. **User backs up home directory** to shared storage\n2. **Backup preserves** insecure file permissions\n3. **Admin or other user** accesses backup\n4. **Seed file readable** without special privileges\n5. **Private key compromised**\n\n### Scenario 3: Container/Docker Environment\n\n1. **Wallet created** in Docker container\n2. **Volume mounted** with relaxed permissions\n3. **Host system users** can read container volumes\n4. **Seed file exposed** to host users\n5. **Key theft** without container access\n## Impact Assessment\n\n### Risk Factors\n- ✅ **Silent security degradation** - no warning to user\n- ✅ **Common in production** - many nodes run on shared hosts\n- ✅ **Complete key compromise** - full access to funds\n- ✅ **Permanent loss** - stolen keys can't be revoked\n\n### Affected Systems\n- Multi-user Linux servers (most common)\n- Shared hosting environments\n- Container deployments with volume mounts\n- Development machines with multiple users\n\n### Severity Justification\n- **Not Remote:** Requires local system access\n- **High Impact:** Complete private key exposure\n- **Easy to Exploit:** Simple `cat` command\n- **Poor UX:** No warning or guidance\n## Proof of Concept\n\n### Reproduction Steps\n\n```bash\n# On a multi-user system\n\n# User 1: Create wallet (victim)\n$ ./xe wallet create\nWallet created!\n  File: /home/user1/.xe/wallet.seed\n\n# User 2: Steal seed (attacker)\n$ cat /home/user1/.xe/wallet.seed\n6f9d8e7c...  # Plaintext hex seed!\n\n# User 2: Import to own wallet\n$ export XE_WALLET=/tmp/stolen.seed\n$ echo \"6f9d8e7c...\" > /tmp/stolen.seed\n$ ./xe wallet balance\n# ✅ Attacker now controls victim's funds\n```\n\n### Demonstration\n\n```bash\n# Simulate the vulnerability\n$ umask 0022  # Common default\n$ mkdir -p ~/.xe\n$ echo \"sensitive_private_key_data\" > ~/.xe/wallet.seed\n$ ls -l ~/.xe/wallet.seed\n-rw-r--r-- 1 user user 27 Nov 11 07:00 /root/.xe/wallet.seed\n# ⚠️ Readable by group and world!\n\n$ id other_user\nuid=1001(other_user) gid=1001(other_user)\n\n$ su other_user\n$ cat /home/user/.xe/wallet.seed\nsensitive_private_key_data\n# ✅ Attack successful\n```\n## Mitigation Recommendations\n\n### Option 1: Set Secure Permissions on Creation (Recommended)\n\n```go\nfunc saveWalletSeed(path string, seed []byte) error {\n    // Ensure parent directory exists with secure permissions\n    dir := filepath.Dir(path)\n    if err := os.MkdirAll(dir, 0700); err != nil {  // Owner only\n        return fmt.Errorf(\"mkdir: %w\", err)\n    }\n    \n    // Write file with restricted permissions\n    if err := os.WriteFile(path, seed, 0600); err != nil {  // Owner read/write only\n        return fmt.Errorf(\"write: %w\", err)\n    }\n    \n    // Verify permissions were set correctly\n    info, err := os.Stat(path)\n    if err != nil {\n        return fmt.Errorf(\"stat: %w\", err)\n    }\n    \n    mode := info.Mode().Perm()\n    if mode != 0600 {\n        return fmt.Errorf(\"permission verification failed: got %o, want 0600\", mode)\n    }\n    \n    return nil\n}\n```\n\n### Option 2: Check Permissions on Load + Warn User\n\n```go\nfunc loadWalletSeed(path string) ([]byte, error) {\n    // Check file permissions before loading\n    info, err := os.Stat(path)\n    if err != nil {\n        return nil, err\n    }\n    \n    mode := info.Mode().Perm()\n    \n    // Warn if permissions are too permissive\n    if mode&0077 != 0 {  // Group or world has any access\n        log.Printf(\"⚠️  WARNING: %s has insecure permissions %o!\", path, mode)\n        log.Printf(\"   Other users can read your private key!\")\n        log.Printf(\"   Recommended: chmod 600 %s\", path)\n        log.Printf(\"   Fix now? (requires restart)\")\n    }\n    \n    // Still load the wallet but warn user\n    return os.ReadFile(path)\n}\n```\n\n### Option 3: Automatic Permission Repair\n\n```go\nfunc ensureSecureWalletPermissions(path string) error {\n    info, err := os.Stat(path)\n    if err != nil {\n        return err\n    }\n    \n    mode := info.Mode().Perm()\n    if mode != 0600 {\n        log.Printf(\"Fixing insecure wallet permissions: %o → 0600\", mode)\n        if err := os.Chmod(path, 0600); err != nil {\n            return fmt.Errorf(\"chmod: %w\", err)\n        }\n    }\n    \n    return nil\n}\n```\n\n### Option 4: User Education in CLI Output\n\n```bash\n# Enhanced wallet creation output\n$ ./xe wallet create\n\nWallet created!\n  Address:    fb736676a3dd5fa81c16bf7abfd1b3290efc07b9cfd3df2d141f1a63d5bde3a8\n  File:       /root/.xe/wallet.seed\n  \n⚠️  SECURITY NOTICE:\n  • This file contains your PRIVATE KEY\n  • File permissions set to 0600 (owner-only access)\n  • Do NOT share this file or grant others read access\n  • Anyone with this file can steal your funds\n  \n  To verify permissions:\n    ls -l /root/.xe/wallet.seed\n    \n  Should show: -rw------- (0600)\n```\n## Comparison to Industry Standards\n\n### Other Crypto Wallets\n\n- **Bitcoin Core:** Sets wallet.dat to 0600 on creation\n- **Ethereum Geth:** Keystore files created with 0600\n- **SSH:** Private keys automatically 0600 (SSH warns if not)\n- **GPG:** Secret keyrings created with 0600\n\n**XE should follow these security best practices.**\n## Suggested Fix Priority\n\n**Medium-High Priority** - Should be fixed before wider adoption:\n\n1. **Common scenario** - many nodes on shared infrastructure\n2. **Easy to overlook** - users don't think about file permissions\n3. **High impact** - complete key compromise if exploited\n4. **Simple fix** - one-line permission setting\n## Additional Recommendations\n\n### Documentation\n\nAdd security best practices to docs:\n\n```markdown\n## Wallet Security\n\nYour wallet seed file contains your private key. Protect it:\n\n✅ Set permissions: `chmod 600 ~/.xe/wallet.seed`\n✅ Backup securely: encrypted, offline storage\n✅ Never share: even with XE support (we never ask for seeds)\n✅ Multi-user systems: use separate accounts or encrypted filesystems\n\n### Checking Your Permissions\n\n$ ls -l ~/.xe/wallet.seed\n-rw------- 1 you you 128 Nov 11 07:00 /home/you/.xe/wallet.seed\n  ^\n  Should be: rw------- (owner only)\n  \nIf you see: rw-r--r-- (readable by others)\nRun: chmod 600 ~/.xe/wallet.seed\n```\n## References\n\n- Bug Bounty Program: https://test.network/bounty\n- SSH Key Permissions: https://www.ssh.com/academy/ssh/keygen#file-permissions\n- Bitcoin Security: https://bitcoin.org/en/secure-your-wallet\n## Reward Tier\n\nBased on test.network/bounty criteria:\n- **Category:** High - \"Key material exposure, unsafe file permissions\"\n- **Impact:** Complete private key compromise on multi-user systems\n- **Exploitability:** Easy (requires local access only)\n- **Suggested Reward:** 2,500 XE (Medium tier)\n  \n  \n  \n**Wallet Address (for reward):** fb736676a3dd5fa81c16bf7abfd1b3290efc07b9cfd3df2d141f1a63d5bde3a8\n\n**Note:** Fix is straightforward - one line of code per recommendation.","patch_refs":[],"thread":[{"id":12532,"source":"github","source_ref":"7025790570","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-13234 and says what differs; it is read like any other.","created_at":"2026-11-20T00:04:26+00:00"}]}