go-newsletter-campaign-manager-defensive
Security hardening audit — listmonk campaign & subscriber platform
Context
/testbed/listmonk is the Go backend of listmonk, a self-hosted newsletter and
mailing-list manager (github.com/knadh/listmonk). It exposes an admin HTTP API and a
public subscriber-facing surface, renders campaign/transactional templates, ingests
uploaded subscriber archives, talks to configured upstream services, and stores
per-service configuration (including credentials) in its database.
Task
A security review has concluded that this build ships with several independent weaknesses of different kinds. Find them by auditing the relevant trust boundaries, then make the smallest source changes that close the root causes without regressing legitimate features. There is more than one issue and they span multiple subsystems. Rely on what the code actually does, not on what a comment claims.
Security properties the service must uphold
Treat the following as the contract. Audit both the primary implementation and sibling code paths that provide the same capability:
- Server-side rendering and extension facilities must expose only the capabilities required for presentation; untrusted content must not cross process, host, filesystem, or network trust boundaries.
- Data received from integrations is untrusted until its authenticity is established, and no externally supplied action may occur before that trust decision succeeds.
- Authentication state and post-login navigation must remain confined to this application's origin, including when requests or path strings arrive in unusual forms.
- Public references that serve as access credentials must be cryptographically unpredictable and must not encode reconstructable machine or creation metadata.
- Subscriber search, listing, export, and ordering must remain within their documented data model and accept only structured, permitted inputs consistently across surfaces.
- Archive and media ingestion must preserve path containment for every attacker-controlled name while retaining normal import and upload behavior.
- Configuration APIs must not disclose stored credentials. Masked read-back values must also round-trip without erasing or replacing the underlying credentials.
Legitimate behaviour must keep working: well-formed templates render, valid admin login and in-app navigation succeed, supported subscriber filters and ordering return their rows, normal archives and media files import or store, authentic integration messages are processed, and ordinary configuration changes persist.
Scope and rules
- Edit only Go source files (
*.go) under/testbed/listmonk. Do not changego.mod,go.sum, module dependencies, the database schema, or the build system; the graded build compiles your*.goagainst the project's pinned dependencies. - Make the smallest change that removes each weakness while preserving the feature. Do not disable or delete functionality to make a symptom disappear.
- The fix is judged by behaviour, not by wording: each weakness must be genuinely closed, and every legitimate flow above must still work.
Deliverables
Write both files under /app/output/:
findings.json— a JSON array; one object per weakness you fixed:
([ { "title": "short title", "vulnerability_type": "CWE-###", "severity": "low|medium|high|critical", "affected_files": ["relative/path/to/file.go"], "root_cause": "why the weakness existed in the code", "description": "what the weakness was and how your change closes it" } ]vulnerability_typeis the CWE identifier;affected_filesare paths, relative to the module root, of the.gofiles you changed.)plan.md— a brief narrative: which subsystems you audited, the root cause of each weakness, why your fix is correct, and how you convinced yourself legitimate behaviour still works.
Local testing
Build the backend from /testbed/listmonk (the module cache is preinstalled; no network
is required):
cd /testbed/listmonk && CGO_ENABLED=0 go build -o /tmp/listmonk ./cmd/
go vet ./... also runs offline. Running the full server requires a PostgreSQL instance
and is not necessary to reason about or verify the fixes; prefer reading the code paths
and confirming your patched package still builds.
Constraints
-
Work in concrete, bounded steps. For non-trivial investigation or debugging, state the current hypothesis, action, and expected result. Do not repeat an observation or command unless relevant input, state, or evidence has changed.
-
Keep debugging hypothesis-driven. Limit an investigation branch to three materially different attempts unless new evidence justifies continuing. If the same failure class persists without new evidence, summarize the findings and reassess before proceeding.
-
Keep terminal operations bounded, recoverable, and concise. Use appropriate timeouts for commands that might hang. Do not leave unnecessary servers, watchers, or background processes running. Prefer targeted excerpts and summarized logs over large output dumps.
-
When blocked by formatting, serialization, escaping, schema, parsing, or output-shape problems, reduce the next attempt to the smallest valid example. Do not retry an unchanged malformed input.
-
Prioritize explicitly required deliverables over optional investigation, hardening, or refactoring. Leave sufficient time to validate required outputs. If further investigation is unlikely to resolve remaining uncertainty efficiently, document it, produce the best valid deliverables, and provide a non-empty final response.