Bounty
XE-13234 · Bounty

Wallet Seed File Permission Vulnerability

Closed · duplicate —claimed Medium xe#361 filed 2026-11-11 07:56 UTC by mhaikalalm

Report

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.

Severity: Medium (2,500 XE)
Type: Local Key Exposure / Insecure File Permissions
File: CLI wallet commands
Commit: 89a542e

Vulnerability Details

Current Behavior

When 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).

$ ./xe wallet create
Wallet created!
  Address:    fb736676a3dd5fa81c16bf7abfd1b3290efc07b9cfd3df2d141f1a63d5bde3a8
  File:       /root/.xe/wallet.seed

$ ls -la ~/.xe/wallet.seed
-rw-r--r-- 1 user user 128 Nov 11 07:00 /root/.xe/wallet.seed
# ⚠️ World-readable! Any local user can steal private key

Root Cause

  • No explicit permission setting in wallet creation code
  • No verification of existing file permissions on load
  • No warning displayed to user about insecure permissions
  • Relies on system umask (varies by environment)

Attack Vector

Scenario 1: Shared Server Environment

  1. User creates wallet on shared VPS/cloud instance
  2. Seed file created with default permissions (644)
  3. Another user on same system runs cat /home/victim/.xe/wallet.seed
  4. Attacker extracts private key from hex seed
  5. Funds stolen from victim's wallet

Scenario 2: Compromised Backup

  1. User backs up home directory to shared storage
  2. Backup preserves insecure file permissions
  3. Admin or other user accesses backup
  4. Seed file readable without special privileges
  5. Private key compromised

Scenario 3: Container/Docker Environment

  1. Wallet created in Docker container
  2. Volume mounted with relaxed permissions
  3. Host system users can read container volumes
  4. Seed file exposed to host users
  5. Key theft without container access

Impact Assessment

Risk Factors

  • ✅ Silent security degradation - no warning to user
  • ✅ Common in production - many nodes run on shared hosts
  • ✅ Complete key compromise - full access to funds
  • ✅ Permanent loss - stolen keys can't be revoked

Affected Systems

  • Multi-user Linux servers (most common)
  • Shared hosting environments
  • Container deployments with volume mounts
  • Development machines with multiple users

Severity Justification

  • Not Remote: Requires local system access
  • High Impact: Complete private key exposure
  • Easy to Exploit: Simple cat command
  • Poor UX: No warning or guidance

Proof of Concept

Reproduction Steps

# On a multi-user system

# User 1: Create wallet (victim)
$ ./xe wallet create
Wallet created!
  File: /home/user1/.xe/wallet.seed

# User 2: Steal seed (attacker)
$ cat /home/user1/.xe/wallet.seed
6f9d8e7c...  # Plaintext hex seed!

# User 2: Import to own wallet
$ export XE_WALLET=/tmp/stolen.seed
$ echo "6f9d8e7c..." > /tmp/stolen.seed
$ ./xe wallet balance
# ✅ Attacker now controls victim's funds

Demonstration

# Simulate the vulnerability
$ umask 0022  # Common default
$ mkdir -p ~/.xe
$ echo "sensitive_private_key_data" > ~/.xe/wallet.seed
$ ls -l ~/.xe/wallet.seed
-rw-r--r-- 1 user user 27 Nov 11 07:00 /root/.xe/wallet.seed
# ⚠️ Readable by group and world!

$ id other_user
uid=1001(other_user) gid=1001(other_user)

$ su other_user
$ cat /home/user/.xe/wallet.seed
sensitive_private_key_data
# ✅ Attack successful

Mitigation Recommendations

Option 1: Set Secure Permissions on Creation (Recommended)

func saveWalletSeed(path string, seed []byte) error {
    // Ensure parent directory exists with secure permissions
    dir := filepath.Dir(path)
    if err := os.MkdirAll(dir, 0700); err != nil {  // Owner only
        return fmt.Errorf("mkdir: %w", err)
    }
    
    // Write file with restricted permissions
    if err := os.WriteFile(path, seed, 0600); err != nil {  // Owner read/write only
        return fmt.Errorf("write: %w", err)
    }
    
    // Verify permissions were set correctly
    info, err := os.Stat(path)
    if err != nil {
        return fmt.Errorf("stat: %w", err)
    }
    
    mode := info.Mode().Perm()
    if mode != 0600 {
        return fmt.Errorf("permission verification failed: got %o, want 0600", mode)
    }
    
    return nil
}

Option 2: Check Permissions on Load + Warn User

func loadWalletSeed(path string) ([]byte, error) {
    // Check file permissions before loading
    info, err := os.Stat(path)
    if err != nil {
        return nil, err
    }
    
    mode := info.Mode().Perm()
    
    // Warn if permissions are too permissive
    if mode&0077 != 0 {  // Group or world has any access
        log.Printf("⚠️  WARNING: %s has insecure permissions %o!", path, mode)
        log.Printf("   Other users can read your private key!")
        log.Printf("   Recommended: chmod 600 %s", path)
        log.Printf("   Fix now? (requires restart)")
    }
    
    // Still load the wallet but warn user
    return os.ReadFile(path)
}

Option 3: Automatic Permission Repair

func ensureSecureWalletPermissions(path string) error {
    info, err := os.Stat(path)
    if err != nil {
        return err
    }
    
    mode := info.Mode().Perm()
    if mode != 0600 {
        log.Printf("Fixing insecure wallet permissions: %o → 0600", mode)
        if err := os.Chmod(path, 0600); err != nil {
            return fmt.Errorf("chmod: %w", err)
        }
    }
    
    return nil
}

Option 4: User Education in CLI Output

# Enhanced wallet creation output
$ ./xe wallet create

Wallet created!
  Address:    fb736676a3dd5fa81c16bf7abfd1b3290efc07b9cfd3df2d141f1a63d5bde3a8
  File:       /root/.xe/wallet.seed
  
⚠️  SECURITY NOTICE:
  • This file contains your PRIVATE KEY
  • File permissions set to 0600 (owner-only access)
  • Do NOT share this file or grant others read access
  • Anyone with this file can steal your funds
  
  To verify permissions:
    ls -l /root/.xe/wallet.seed
    
  Should show: -rw------- (0600)

Comparison to Industry Standards

Other Crypto Wallets

  • Bitcoin Core: Sets wallet.dat to 0600 on creation
  • Ethereum Geth: Keystore files created with 0600
  • SSH: Private keys automatically 0600 (SSH warns if not)
  • GPG: Secret keyrings created with 0600

XE should follow these security best practices.

Suggested Fix Priority

Medium-High Priority - Should be fixed before wider adoption:

  1. Common scenario - many nodes on shared infrastructure
  2. Easy to overlook - users don't think about file permissions
  3. High impact - complete key compromise if exploited
  4. Simple fix - one-line permission setting

Additional Recommendations

Documentation

Add security best practices to docs:

## Wallet Security

Your wallet seed file contains your private key. Protect it:

✅ Set permissions: `chmod 600 ~/.xe/wallet.seed`
✅ Backup securely: encrypted, offline storage
✅ Never share: even with XE support (we never ask for seeds)
✅ Multi-user systems: use separate accounts or encrypted filesystems

### Checking Your Permissions

$ ls -l ~/.xe/wallet.seed
-rw------- 1 you you 128 Nov 11 07:00 /home/you/.xe/wallet.seed
  ^
  Should be: rw------- (owner only)
  
If you see: rw-r--r-- (readable by others)
Run: chmod 600 ~/.xe/wallet.seed

References

  • Bug Bounty Program: https://test.network/bounty
  • SSH Key Permissions: https://www.ssh.com/academy/ssh/keygen#file-permissions
  • Bitcoin Security: https://bitcoin.org/en/secure-your-wallet

Reward Tier

Based on test.network/bounty criteria:

  • Category: High - "Key material exposure, unsafe file permissions"
  • Impact: Complete private key compromise on multi-user systems
  • Exploitability: Easy (requires local access only)
  • Suggested Reward: 2,500 XE (Medium tier)

Wallet Address (for reward): fb736676a3dd5fa81c16bf7abfd1b3290efc07b9cfd3df2d141f1a63d5bde3a8

Note: Fix is straightforward - one line of code per recommendation.

Thread

Joseph Denneteam2026-11-20 00:04 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13234 and says what differs; it is read like any other.