Skip to content

Fix security and correctness issues: auth bypass, PIN detection, network drift, timer leak#791

Merged
orbitlumen-hue merged 4 commits into
DogStark:mainfrom
Almikefred:feature/fix-security-auth-correctness-issues
Jul 24, 2026
Merged

Fix security and correctness issues: auth bypass, PIN detection, network drift, timer leak#791
orbitlumen-hue merged 4 commits into
DogStark:mainfrom
Almikefred:feature/fix-security-auth-correctness-issues

Conversation

@Almikefred

Copy link
Copy Markdown
Contributor

Summary

Resolves four security and correctness issues across ZKP service, wallet recovery, network detection, and auth token management:

  • Removes unauthenticated access to proof listings
  • Fixes browser-incompatible error detection
  • Consolidates duplicated network detection logic
  • Prevents token-refresh interval leaks from concurrent timers

Changes

#708 — zkp.ts getProofsForPet bypasses auth

  • Create /api/zkp/pet/[petId] route to proxy backend with authentication
  • Update zkpService.getProofsForPet() to route through internal API
  • Attaches auth token consistent with generateProof and verifyProof

#709 — WalletRecovery PIN detection relies on fragile string matching

  • Create DecryptionError class for typed error handling
  • Update decryptSecretKey() to wrap Web Crypto API failures
  • Replace substring matching with instanceof check in WalletRecovery
  • Works reliably across all browsers/engines

#710 — Network detection logic duplicated in 3 places

  • Extract getStellarNetwork() and isTestnetNetwork() to src/lib/blockchain/network.ts
  • Update walletService, blockchain/index, and wallet.tsx to use shared helper
  • Single source of truth eliminates drift risk

#711 — AuthContext token-refresh timer stored in closure variable (HIGH priority)

  • Move refreshTimer from plain let to useRef for cross-render persistence
  • Add useEffect cleanup to clear interval on unmount
  • Prevents duplicate/racing refresh calls from orphaned intervals

Closes #708, Closes #709, Closes #710, Closes #711

- Move refreshTimer from plain let to useRef so handle survives renders
- Add useEffect cleanup to clear interval on unmount
- Eliminates duplicate/racing refresh calls from leaked intervals
…gStark#710)

- Create src/lib/blockchain/network.ts with getStellarNetwork() and isTestnetNetwork()
- Update walletService, blockchain/index, and wallet.tsx to use shared helper
- Eliminates duplicate network detection logic and reduces drift risk
…ark#709)

- Create DecryptionError class to wrap Web Crypto API failures
- Update decryptSecretKey() to catch DOMException and re-throw as DecryptionError
- Update WalletRecovery to check instanceof instead of fragile message substrings
- Improves reliability across different browsers/implementations
…rk#708)

- Create /api/zkp/pet/[petId] route to proxy backend with auth
- Update zkpService.getProofsForPet to use internal route instead of direct backend
- Attaches auth token consistent with other zkp methods and app patterns
@orbitlumen-hue
orbitlumen-hue merged commit b364005 into DogStark:main Jul 24, 2026
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment