Vibe Coding Security
Map what your coding agent can touch
Map assets and trust boundaries, write abuse stories and limit the coding agent’s task.
- Run a small app locally.
- Read basic JavaScript or TypeScript.
- Follow an HTTP request.
- Use environment variables.
- Save or review changes with Git.
- Next.js App Router.
- React.
- TypeScript.
- PostgreSQL through node-postgres.
- The Stripe Node SDK.
- GitHub Actions.
- PocketDesk is fictional. Its people, records, prices and incidents are fictional too.
- These selected educational patterns are not a complete PocketDesk starter app or a complete security implementation.
- Labs use only your own local or isolated app with synthetic data. No third-party testing is authorised.
- Labs are self-checked, not automatically inspected. They are not a penetration test or a certification that your app is secure. Passing the course shows assessed learning. It does not provide independent assurance of PocketDesk or promise that incidents can no longer happen.
By the end of this chapter
- Identify assets and realistic misuse in a small SaaS.
- Trace trust boundaries across the complete feature.
- Constrain coding-agent tools, data, and authority.
- Prioritise controls using a concrete failure story.
List assets and what could happen to them
A private note is an asset because disclosure can harm the client. A session token can let someone act as an account. Billing state controls paid access. Source code, deployment permissions, signing secrets and backups also matter. For each asset, explain what harm its loss or misuse could cause. A list of database tables is not enough.
Include these actors and their capabilities:
- An unauthenticated visitor.
- A legitimate workspace member.
- A revoked member who still has an old link.
- A compromised dependency.
- An imported document containing hostile instructions.
Do not assume every attacker starts with administrator access. Include accidental harm too: a generated migration deletes notes, or a debugging response includes private records.
Map the request and who controls each step
PocketDesk request and access map
- 1Browser
Untrusted request fields and the user’s session.
- 2Application server
Checks the request before granting access.
- 3Private storage
Tenant-scoped notes, files, and operational records.
- 4External services
Stripe, email, and optional AI processing.
- 5Build and deploy
Coding agent, dependencies, CI runner, and limited credentials.
The application server checks:
- Identity.
- Workspace membership.
- The requested action.
- Input.
- Paid entitlement.
A trust boundary is a point where control or authority changes. The browser can propose a note ID. It cannot declare itself the note’s owner. Stripe can supply a signed payment event. The app must still map it to the correct internal account and product. A coding agent can suggest code. Tool permissions determine whether it can run a destructive command.
Restrict the coding agent’s tools and access
Give the agent a narrow task, a disposable branch, synthetic fixtures and only the tools it needs. Keep live customer exports, production secrets, cloud administrator credentials and unrestricted database access outside its workspace. The execution environment must enforce network and filesystem permissions. A prompt saying “do not read secrets” does not withhold access to them.
| Tempting instruction | Safer task boundary |
|---|---|
| Fix everything and deploy when it looks good. | Implement one note-read path; show the diff and local test results. |
| Use this production database to reproduce the bug. | Use two synthetic workspaces in a disposable database. |
| Run any installation script needed to make tests pass. | Explain each new dependency and inspect commands before execution. |
| Ignore failing checks so the demo works. | Keep the failed check visible and explain the underlying assumption. |
Review what the patch changes. Look for:
- New external calls.
- Permission checks removed for convenience.
- Broadly scoped credentials.
- Disabled tests.
- Changed package scripts.
- Data returned to the client.
A passing build shows that the build succeeded under its test conditions. It does not show that Cy cannot read Ada’s notes.
Turn an access failure into a test
Write: “Cy can change a note ID and retrieve a note in workspace A because the read endpoint checks sign-in but not membership.” Add a server-side authorisation check for the note’s workspace. Test it with two owned synthetic accounts. Confirm that the wrong-workspace request returns no private note. This gives you a specific control and test, rather than a task called “add enterprise security.”
Prioritise by consequence, reachability, exposure and the test results or records you have. A public cross-workspace read needs attention before a cosmetic warning. Record unknowns and restrict release where needed. Review the threat model when a new connector, role, payment action or AI tool changes what the feature can do.
Optional isolated practice
Optional independent practice
Draw the PocketDesk threat map
Optional solo lab: Sketch the note-read and AI-summary flows. Add one attacker story and one accidental-agent failure, then identify where each must be stopped. Use only an application you own on localhost or an explicitly isolated test environment, synthetic accounts, and disposable data. A written walkthrough is sufficient if you have no running app. Keep your practice notes locally.
- Asset and boundary map.
- Two failure stories with controls and observable tests.
| Self-check | Evidence in your notes |
|---|---|
| Assets | Explain consequences for notes, sessions, billing, secrets, and backups. |
| Boundaries | Mark browser, application, storage, external services, and agent tooling. |
| Authority | Separate proposed input from server-derived permission. |
| Test | State a failing condition and the evidence that would show it is blocked. |
Chapter assessment
Take the chapter assessment on assets, trust boundaries, agent access and threat-model tests.
Sources and further reading
- OWASP: Threat Modeling
Model the system, threats, mitigations, and whether the mitigations work. Checked 16 November 2026.
- OWASP Application Security Verification Standard
Security requirements framework; official site currently offers ASVS 5.0.0. Select and version relevant requirements; this course is not an ASVS assessment or certification. Checked 16 November 2026.
- Docker: Compose uses
Optional disposable local services; not a required course dependency. Checked 16 November 2026.
- Mailpit: Test email capture
Optional local SMTP capture and inbox for synthetic email tests. Checked 16 November 2026.
- Stripe: CLI
Optional Stripe test tooling; use its current installation and webhook-forwarding instructions. Checked 16 November 2026.
Original Slim Prep teaching.
Required project checkpoint
Map the PocketDesk trust boundaries
Set up the dossier and identify what the app and coding agent can access.
Start with
Read the PocketDesk case and choose source-inspection or your own isolated-app route. Open the Security field pack at /courses/vibe-coding-security#course-resources. It is a workbook and template pack, not a runnable starter.
Record your route
Create a dossier front page. Name the case, source chapter, and route. If inspecting a learner-owned app, record its local version and disposable environment. Otherwise write source inspection and leave execution not run.
Expected result. An evidence label that prevents later plans being mistaken for executed tests.
Draw users and assets
Place Ada and Ben in workspace A and Cy in B. Draw browser, app server, database, billing service, optional summariser, and the coding agent. Mark private notes, credentials, sessions, subscriptions, and code as assets.
Expected result. A boundary diagram that distinguishes the app’s users from the tool building it.
Follow a private-note request
Trace a signed-in request through session, membership, permission, and record scope. Mark where a browser-supplied workspace or note identifier must be checked rather than trusted.
Expected result. A numbered request path with authority checks at the server boundary.
Limit the coding agent
Write what the agent needs for a local change and what it should not receive, such as production credentials or unrestricted cloud access. Identify when a new package, MCP tool, network access, or deployment needs a separate review.
Expected result. An agent-permission proposal linked to actual development tasks.
Save the review questions
Write the promises you will inspect across the course: permitted note access, denied cross-workspace access, safe recovery, verified billing, and bounded optional summaries. Link each promise to its later milestone.
Expected result. The first indexed record and a list of questions the project must resolve.
Save these outputs
- Dossier scope, trust-boundary diagram, private-note request path, and coding-agent permission proposal.
If you get stuck
- My diagram says “authenticated = allowed.”
- Separate session identity from workspace membership, permission, and record-level access.
- I have no local app.
- Use the provided case and snippets. Write expected outcomes and keep execution not run; the source-inspection route is supported.
Your checkpoint template
Record: PocketDesk scope and boundaries Route: source inspection / learner-owned isolated app Source or app version: Users and workspace membership: Assets and components: Private-note request path: Server authority checks: Coding-agent permitted capabilities: Capabilities requiring separate review: Promises to inspect: Observed evidence / not run:
In the student classroom, save this checkpoint in the project workspace. After the final chapter, send the complete project for instructor review. This owner review shows the instructions; it does not save or send learner work.