Skip to content

Fix unsanitized $_GET params and missing null checks in REST API#1314

Open
jbrejcha wants to merge 14 commits intohtmlburger:developmentfrom
jbrejcha:fix/sanitize-rest-api-get-params
Open

Fix unsanitized $_GET params and missing null checks in REST API#1314
jbrejcha wants to merge 14 commits intohtmlburger:developmentfrom
jbrejcha:fix/sanitize-rest-api-get-params

Conversation

@jbrejcha
Copy link
Copy Markdown

Problem

In get_association_data() and get_association_options(), container_id and field_id are read from $_GET without sanitization and without an isset() check. The return value of Helper::get_field() is also used without a null check — passing an unknown field ID causes a fatal error.

Changes

  • sanitize_text_field() + isset() on container_id and field_id in both methods
  • Null check on Helper::get_field() before calling methods on the result
  • array_pad() on explode(':', $option) to prevent undefined index when option string has fewer than 3 parts
  • in_array() strict mode in Router and Decorator

jorostoyanov and others added 14 commits November 10, 2023 17:49
- sanitize_text_field() on container_id and field_id in
  get_association_data() and get_association_options()
- Guard against null return from Helper::get_field() before
  calling methods on the result (prevents fatal error on unknown field)
- array_pad() on explode(':') result to prevent undefined index
  when option string has fewer than 3 parts
- in_array() strict mode (true) in Router and Decorator

Fixes potential fatal errors and input validation issues in the
Association field REST API endpoints.
@jbrejcha jbrejcha changed the base branch from master to development April 11, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants