CakePHP 5.4

Last reviewed Sep 24, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. PHP 8.5145 lines · 5.4K tokens
  2. CakePHP 5.487 lines · 4.6K tokens
Total232 lines · 10K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 78
  • 79
  • 88
  • 89
  • 93
  • 95
  • 98
  • 117
  • 187
  • 201
  • 208
  • 209
  • 214
  • 252
  • 256
  • 295
  • 306
  • 323
  • 338
  • 340
  • 352
  • 354
  • 362
  • 367
  • 384
  • 390
  • 404
  • 409
  • 413
  • 434
  • 470
  • 488
  • 502
  • 522
  • 524
  • 525
  • 532
  • 552
  • 601
  • 611
  • 613
  • 614
  • 639
  • 674
  • 675
  • 732
  • 770
  • 776
  • 798
  • 799
  • 807
  • 829
  • 862
  • 915
  • 916
  • 918
  • 940
  • 942
  • 1004
  • 1275
  • 1287
  • 1333
  • 1395

Prompt Preview

Apply the PHP 8.5 baseline first. These rules cover CakePHP 5.4 on PHP 8.5; the line requires PHP 8.2 or later. Apply the authentication and authorization plugin rules when those plugins are installed.

Requests, routing, and proxy trust

  • Wrap downstream request processing with ErrorHandlerMiddleware. Run RoutingMiddleware before checks that use route parameters, and BodyParserMiddleware before authentication or CSRF checks that consume parsed bodies. Review middleware coverage for plugin, prefix, fallback, and API routes.
  • Restrict routes to their intended verbs and call $request->allowMethod() in mutation actions. Keep GET and HEAD free of mutations. Account for _method and X-Http-Method-Override; inspect ORIGINAL_REQUEST_METHOD or reject overrides where the endpoint requires the original transport verb.
  • Enforce accepted media types and body-size limits before parsing. BodyParserMiddleware enables JSON and disables XML by default; its JSON decoder casts valid scalar and null values to arrays. Use addParser() with strict decoding and explicit top-level shape checks when the contract requires an object or list; do not treat successful parsing as validation.
  • Give #[RequestToDto] an explicit RequestToDtoSource::Body or ::Query where only one source is allowed. Auto can fall back to query parameters when a mutation body is empty, and Request merges query and body data. Validate fields and invariants in the DTO's createFromArray() path before business use.
  • Enable ServerRequest::$trustProxy or call setTrustedProxies() only behind an