Security by Design in Planned Wallet: Authentication, Bot Protection, and OWASP Testing
Part of my planning and design of Planned Wallet was to build an app I would be comfortable using to track my finances. For 25 years, I’ve managed my savings, retirement, checking, and credit card accounts in a massive spreadsheet. First it was locally in Excel, then moved to the cloud, then over to Google docs. It has always felt clunky, but gotten the job done. It was never pretty, and history would inevitably be lost over time as I would change how I wanted to organize my data, but I knew to the penny what I made and what I spent over the most recent years.
Now, with Gemini and Copilot embedding themselves into spreadsheets, my data was becoming more and more exposed. I use AI to build, design, review, and brainstorm. I am not a fan of having AI monitor me and my personal data, which let’s face it, is where we are headed. Planned Wallet is my attempt to use AI to design, build, and deliver a product that doesn’t have AI scraping the data for ingestion. I just don’t want AI looking at my data as a means to inform vendors (the Amazons, Walmarts, Krogers of the world) about how much I have to spend.
For me to be comfortable with my own app for hosting my financial data:
- My data had to be encrypted at rest.
- My data had to be transmitted encrypted all the way to the app code (container).
- The connection to the database had to be encrypted (TLS required).
- The login exchange for access (authN/authZ) had to require MFA on Every. Single. Login.
- No browser auto-login, retained session, cookies, or HTML 5 storage making it easy for a compromised browser session to lead to exposure of my financial data.
- Enforced an enterprise grade WAF for brute force login attempts, XSS, SQL injection, rate limits, bot restriction, and other expected WAF protections.
- Dependency monitoring and 3rd party library inspection/scanning.
These were the guiding principals I adopted when starting to build out Planned Wallet. The features sitting behind these principals is just an AI-prohibited data retention service. All manual entry, no data brokers.
I outline the approach and tools used below.
1. Authentication & Session Lifecycle
Short-Lived 15-Minute JWTs & Activity-Based Refresh
- Short lived tokens: 15 minute JWTs are issued and expire based on username, password, and MFA challenge. They are issued HMAC-SHA256 JWTs with a 256-bit shared secret across the containers.
- JWT expiration: While a user is actively interacting with the browser via clicks or typing, the session is maintained by a token refresh, exchanging a current valid token for a newer one with a fresh 15 minute activity window. Should I put the tab in the background, or step away for a few minutes, the RAM-stored (not HTML-storage) JWT is discarded, rendering the session dead.
Mandatory TOTP Two-Factor Authentication (MFA)
- Every registered account is provisioned with an RFC 6238 TOTP secret at registration time. There is no method to login without MFA.
- Password exchange verifies both the bcrypt-hashed password (enforcing complexity rules and a 72-byte UTF-8 ceiling to prevent silent bcrypt truncation) and a valid 6-digit TOTP code. Integration tests have been designed to explicitly validate that account presence vs account credential failure respond in an identical manner so account enumeration cannot be brute forced.
Single-Use 12-Word Account Recovery Keys
- Instead of insecure email-reset links, registration issues a single-use 12-word recovery phrase hashed with Argon2id. I wanted as little email spam as possible, and I did not want compromised email accounts leading to compromised financial records. If you lose your 12-word account recovery key, there is no path to recover your account without your username, MFA token, and password. This was a conscious design choice to favor data security over account recovery.
- Account recovery verifies the CAPTCHA and recovery phrase. The exchange atomically enforces a password change, generates a new TOTP secret (MFA), and generates a new recovery phrase. The reset records
used_atandused_ipon the consumed key for future audits.
2. Bot Protection & Edge Perimeter
Visual PNG CAPTCHA Verification
- Self-registration and credential recovery are guarded by server-generated visual PNG CAPTCHA challenges. These tend to be a bit more beatable than Google’s annoying “click the boxes containing X”, but sufficient enough to restrict amateur adversaries. The risk is a bunch of garbage data accounts being created, which I would have to clean up. Integrating with a 3rd party, like Google’s CAPTCHA, may be required at some point in the future but feels a bit premature in a startup model.
Edge & Origin Verification
- Every API request requires an
X-Client-IDheader, correlated with W3C Trace Context (traceparent) logs across handlers and controllers. This API requirement offers very little bot protection, but will prevent the most basic of API scans. In reality, I write about the justification for theX-Client-IDin my book as a means to better support client identification for contract breaks and maintenance efforts. - The back-end golang microservice enforces the CloudFront Origin header
X-Origin-Verifymatches the environment mounted secret. This is the detail CloudFront provides as a WAF to “seal” traffic from CloudFront to the golang container. The container, hosted on AWS App Runner, has a public IP assigned but it is unreachable from the internet based on networking rules. The App Runner instance currently accepts traffic only from the API Gateway Private VPC Link. Direct traffic to the container’s public IP is dropped at the AWS network layer.
3. Data Layer & Authorization Controls
Only Prepared Statements Allowed
- All PostgreSQL queries use parameterized
$1, $2, ...placeholders to prevent SQL injection. I have agents scan this as part of the agent directives. - Structured JSON preferences (
user_settings.settingsJSONB) are bound to typed Go structs, validated for UUID format and strict array caps (<= 200/<= 300entries), and marshaled viajson.Marshalbefore being passed as a bound$3::jsonbparameter—eliminating SQL injection vectors.
Anti-Enumeration Access Control
- Requests from users without an access grant return
404 Not Foundrather than403 Forbidden, preventing attackers from enumerating private account UUIDs.
4. OWASP-Aligned Validation & Integration Testing
Security controls are only as reliable as their automated verification. Planned Wallet pairs fast Go unit tests (against an in-memory repository with identical error semantics) with a Playwright + Pytest integration suite that run against a completely wiped PostgreSQL database on every CI/CD pipeline. Tests are maintained, along with agent scans, along with WAF protections to ensure proper access controls and API safeguards.
Automated security and OWASP-style checks in the suite include:
- SQL Injection: Sends SQL injection payloads across account names, descriptions, logins, recovery inputs, and checking ledgers, asserting clean rejection (
400/401) and intact database state. - Broken Access Control / IDOR: Verifies cross-user isolation across accounts, snapshots, asset stores, perspectives, and user settings (
404/403enforcement). - Authentication & Input Boundaries: Tests invalid TOTP rejection, duplicate user conflict handling, 72-byte password boundary enforcement, 11-of-12 / reordered recovery phrase rejection, and single-use phrase rotation.
- Perimeter & Tracing: Confirms requests missing
X-Client-IDare rejected and W3Ctraceparentheaders propagate end-to-end.