Pentmax devlog #0: planning before the first line of code
Why I'm building a self-hosted pentest platform, who it is for, and the security and architecture decisions I made before writing any code, including the ones I threw away.
Pentmax is my first open source project: a self-hosted platform that follows a penetration test from scope to sign-off. This first devlog entry contains no code, and that is deliberate. Phase 0 produced a planning document, a roadmap and twelve Architecture Decision Records (ADRs: short documents that record one decision, its context and its consequences). The most valuable outcome was not a decision I made but one I reversed: the first design was built for the wrong user.
The problem#
A pentest tool holds some of the most sensitive data a client has: confirmed vulnerabilities, working exploit paths, test credentials, screenshots of internal systems. You would expect that data to live in one well-protected place. For a solo tester or a team of three, it usually lives in five.
Findings and the report sit in a reporting tool. The scope is in a spreadsheet. The authorization is an email, or a phone call someone remembers. The client’s test credentials arrived over a messenger. The retest request is buried in a mail thread six months later.
Each of those tools does its own job well. The incidents happen in the gaps between them: testing a host that was never in scope, starting before anybody agreed to it, a credential that is still valid a year after the engagement ended. None of these is a hard technical problem. They are bookkeeping failures, and bookkeeping is exactly what software should do for us.
So the goal is one system of record for the whole engagement: scoping, authorization, testing, findings, reporting, delivery, remediation, retest and retention. Structured findings and good PDF reports are the core, and other tools already do them well. The lifecycle around them is where Pentmax wants to be different.
Ground rules#
Before deciding anything about the product, I set the rules for how it gets built:
- Plan before code.
- An ADR for every non-trivial decision, compromises included.
- One milestone part at a time, each finished only when tests demonstrate its acceptance criteria.
- Secure by default, and every exception is written down with its reason.
- An honest log per phase, which is where this devlog comes from.
The second rule matters more than it looks. A security decision that exists only in someone’s head cannot be reviewed, and a compromise that isn’t written down quietly becomes the default.
The decisions in one table#
| Area | Decision |
|---|---|
| Deployment | Self-hosted, one organization per instance, everything in Docker Compose |
| Backend | Go, a single static binary that embeds the web UI |
| Database | MySQL 8.4 LTS |
| Frontend | React + TypeScript, API client generated from the OpenAPI spec |
| Data access | sqlc: hand-written SQL, compiled into typed and always parameterized queries |
| Typst in an isolated renderer container with no network | |
| Roles | admin, pentester (assigned engagements only), client (portal only) |
| Workflow | Acknowledged warnings instead of hard gates; a verbal authorization is a real record |
| Reports | English first, with the localization model built in from day one |
| MFA | Multi-factor authentication (TOTP, WebAuthn), mandatory for every role, a release blocker |
Designed for the wrong user#
The first draft of the plan was built for an audited consultancy. It had hard workflow gates (“no testing without a signed authorization letter”), four-eyes approval on everything, per-engagement roles such as lead, tester, reviewer and viewer, and admins without default access to engagement data.
Each of those controls is reasonable for a 50-person firm with a compliance team. For a solo tester whose client said “go ahead” on the phone, they are bureaucracy, and bureaucracy gets worked around.
The more important insight was that hard gates destroy the evidence trail they are supposed to create. If the tool refuses to move an engagement into Testing without an uploaded authorization document, people upload whatever makes it move: an empty PDF, last year’s letter, a screenshot of a calendar invite. The record now says “signed authorization on file”, and it is false. A control that produces false records is worse than no control, because people trust it.
So Pentmax does the opposite. A state change with unmet preconditions doesn’t fail. The server returns a list of warnings, and the user has to acknowledge them explicitly, with a written reason, before the change goes through. The acknowledgement goes into the audit log. A verbal authorization is a first-class record type, with the person who granted it and the time. The resulting record is less flattering (“started testing on a verbal OK from the CTO, no testing window recorded”), but it is true, and a true record is what you need when something goes wrong.
Why Go#
The textbook choice for this kind of application would be Python/Django with PostgreSQL. Django has the strongest security defaults of any mainstream web framework, and Python has WeasyPrint and docxtpl for PDF and DOCX generation in the same runtime. I chose Go, for reasons that come from what Pentmax is: a server that holds every client’s most sensitive data.
- Less code runs in production. The image contains one static binary with the UI embedded: no interpreter, no package manager, no shell. That allows a distroless, non-root, read-only container. An attacker who gets code execution finds very little to work with, and there is very little that needs patching.
- A smaller supply chain. Go’s standard library covers most of what a web backend needs: HTTP, TLS, cryptography, JSON, even cross-origin request protection. Every dependency I don’t pull in is one I don’t have to audit, pin and patch.
- The compiler and the toolchain catch bugs early. Refactoring an authorization layer without static types is not something I want to do. The race detector finds concurrency bugs during tests, and in an application with locks, quotas and counters, concurrency bugs are often security bugs.
- Explicit beats implicit. Without a framework handling sessions, CSRF and permissions behind the scenes, every security mechanism is code in the repository that I can read, test and explain. That costs more work, and it is the main risk of this choice. But nothing security-relevant happens by convention.
- Isolation by necessity. Go is weak at PDF and DOCX generation, so rendering has to run in a separate engine. That pushed it into its own container, which is exactly where code that processes hostile content belongs.
The same binary also serves as the administration and verification CLI, so the server and its tooling share one codebase.
MySQL over PostgreSQL was the smaller decision. PostgreSQL’s row-level security would be a nice second layer, but Pentmax’s authorization is designed to live in the application and to be tested there, not to depend on database policies. MySQL is also the database small hosting setups already run and know how to back up.
What I rejected#
- Per-engagement roles. Enterprise RBAC for a team of three. More roles mean more combinations to test and more ways to get one wrong.
- Configurable engagement visibility (
allorassigned). A single wrong setting would expose every client’s data to every tester, and it doubles the authorization test matrix. Pentesters see their assigned engagements, admins see everything, and there is no switch to get wrong. - Headless Chromium for PDFs. It has the best CSS support, but it is a full browser engine processing content that is, by definition, full of XSS payloads.
- A WeasyPrint sidecar. No JavaScript execution, but it brings a whole Python runtime into a Go stack only to render documents.
- Multi-tenant SaaS, or a “tenant-ready” data model just in case. One organization per instance puts the isolation boundary at the deployment level, where a bug in my code cannot cross it.
Security starts with the threat model#
Most of the security design follows from three questions: what does this tool hold, who touches it, and what is the worst thing it could do?
Finding content is hostile by design. Pentesters paste real payloads into findings: script tags, template injection strings, SQL. That one fact drove three decisions. Markdown in the UI goes through a restricted pipeline under a strict Content Security Policy (CSP), the browser-enforced list of what a page may load and run. Report content goes into Typst as JSON data and is never concatenated into template source. The renderer runs in a container with no network, a read-only filesystem and resource limits.
Cross-client data access is the top risk. The worst thing this application can do is show client A’s findings to someone working for client B. That bug class is called IDOR (insecure direct object reference): the server returns an object because the request named it, without checking that the requester may see it. The defenses are structural rather than “remember to check”:
- access is filtered in the SQL query itself, never by discarding rows afterwards;
- a foreign object returns
404instead of403, so the response doesn’t even confirm that it exists; - a route without an authorization policy fails the build;
- a generated test runs every role against every route, on its own objects and on foreign ones.
The client portal is a separate API surface with its own allow-listed response types. Adding an internal field to a model cannot leak it to clients by accident, because the portal only ever returns fields that were explicitly listed for it.
The audit log has to be tamper-evident. Each entry is chained to the previous one by a hash, database triggers block UPDATE and DELETE, the application’s database account can only INSERT and SELECT on that table, and a verify command checks the chain.
No default credentials, ever. The first admin account is created from the command line on the server.
Evidence may be malware. Uploaded files are stored opaquely and downloaded only as attachments, images are re-encoded before display, and decompression bombs are bounded before they are decoded.
Honest trade-offs#
- Go over Django means assembling and auditing security plumbing myself: sessions, CSRF protection, input validation. I compensate with the standard library where it is strong (Go’s
CrossOriginProtection, for example), generated code (OpenAPI, sqlc), and tests that assert security properties instead of trusting a framework to have them. - MySQL over PostgreSQL gives up row-level security and transactional DDL, which means a failed migration can leave the schema half-changed. Authorization never relied on the database, but migrations have to be written defensively.
- Typst over HTML/CSS makes rendering much safer and the output reproducible, but template authors have to learn a new language, and I have to write the Markdown-to-document converter myself. If Typst’s sandbox doesn’t hold up when I verify it in M4, headless Chromium behind Gotenberg is the documented fallback.
- Admins see all engagements. Simple, and realistic for small firms, but it makes an admin account a high-value target. That is a big part of why MFA is mandatory for every account and blocks the first release.
- Finding text is not encrypted at the application level, so it stays searchable and renderable. Disk encryption is a documented requirement for the operator.
Next#
M0, the foundation: an empty but production-shaped skeleton with every quality and security gate already running, so that every later feature is born into a safe environment. Standard-library routing, a spec-first API, pinned tooling, distroless containers, and a CI pipeline that fails when someone plants a vulnerable dependency or a fake secret.