liveBook · Manning

Attack-scenario prompting

As explained in Coding with AI

Attack-scenario prompting asks an AI system to design or evaluate an implementation against specified security attacks.

Attack-scenario prompting asks an AI coding assistant to implement or evaluate a feature against named security attacks, making threats explicit before code generation. section 9.6.1

Authentication prompt

Implement JWT authentication that prevents token replay attacks, timing attacks, brute-force attempts, and token theft via XSS. Review the generated implementation rather than accepting it unchanged. section 9.6.1

Use the technique by naming the security scenarios the implementation must address:

<requirements>...</requirements>
<implementation>...</implementation> 
<tests>...</tests>

Organize the request into requirements, implementation, and tests so attack scenarios shape both the generated code and its validation. section 9.6.1

How Coding with AI covers it

How deep it goes
Demonstrates attack-specific requirements but does not explain defensive implementation details or threat-modeling internals.
Examples
Uses a JWT authentication prompt targeting replay, timing, brute-force, and cross-site scripting attacks.
What you can do after
Apply it via an AI coding assistant to request security-aware implementations and tests.
How it connects
Connects authentication with JWT, token replay attacks, timing attacks, brute-force attacks, and cross-site scripting.

This explainer was generated by Manning's knowledge graph from the text of Coding with AI. The section links point to the parts of the book it draws on.