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:
- Token replay attacks section 9.6.1
- Timing attacks section 9.6.1
- Brute-force attempts section 9.6.1
- Token theft through cross-site scripting section 9.6.1
<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
