Performance: Server action security considerations
HIGH IMPACT
This affects the security and integrity of server-side operations, indirectly impacting user trust and interaction speed by preventing malicious delays or data leaks.
'use server' export async function action(data) { // Validate and sanitize input before use const safeName = sanitize(data.name); await db.query('SELECT * FROM users WHERE name = ?', [safeName]); }
'use server' export async function action(data) { // Directly use user input in database query without validation await db.query(`SELECT * FROM users WHERE name = '${data.name}'`); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unsafe server action with no validation | N/A | N/A | Blocks server response causing delayed paint | [X] Bad |
| Validated input with parameterized queries | N/A | N/A | Fast server response enables quick paint | [OK] Good |
| Excessive data returned from server action | N/A | N/A | Large payload delays paint and interaction | [X] Bad |
| Minimal data returned with filtering | N/A | N/A | Small payload speeds up paint and interaction | [OK] Good |
| No authentication on sensitive actions | N/A | N/A | Server overload blocks response and paint | [X] Bad |
| Authentication enforced before action | N/A | N/A | Prevents overload, keeps response fast | [OK] Good |