Skip to content

Fix unslashed superglobal input and PHPCS/WPCS violations - #521

Open
miyanialkesh7 wants to merge 3 commits into
WordPress:trunkfrom
miyanialkesh7:alkesh-security-fixes
Open

Fix unslashed superglobal input and PHPCS/WPCS violations#521
miyanialkesh7 wants to merge 3 commits into
WordPress:trunkfrom
miyanialkesh7:alkesh-security-fixes

Conversation

@miyanialkesh7

Copy link
Copy Markdown

Ran composer lint:php (PHPCS/WPCS) against the plugin source and fixed the issues found:

  • Security: $_REQUEST and $_SERVER superglobal values were used before being unslashed, which trips WordPress.Security.ValidatedSanitizedInput.MissingUnslash. WordPress adds slashes to all superglobal data (wp_magic_quotes()), so without wp_unslash() first, sanitizers like wp_kses() can leave stray backslashes in stored/output values for any input containing a quote or backslash character. Fixed in:
    • acf_request_args() and acf_request_arg() in includes/acf-helper-functions.php ($_REQUEST)
    • acf_get_current_url() in includes/acf-helper-functions.php ($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])
  • WPCS formatting: applied phpcbf auto-fixes for minor coding-standard violations in includes/admin/views/tools/tools.php, includes/rest-api/acf-rest-api-functions.php, and includes/rest-api/class-acf-rest-embed-links.php (whitespace/alignment only, no logic changes).

Scope note: a full-repo PHPCS scan turned up a large amount of pre-existing style/doc-comment debt (thousands of violations across ~180 files, mostly Generic.Commenting.DocComment.ShortNotCapital, missing method visibility, Yoda conditions, etc.). That's left untouched here since it's unrelated to security and would be a huge, hard-to-review diff — happy to open a separate, narrower follow-up if maintainers want that cleaned up incrementally.

Closes

Use of AI Tools

This PR was prepared with the assistance of Claude Code (Anthropic). The PHPCS/WPCS scan was run and reviewed, the wp_unslash() fixes were written and verified (syntax check + targeted PHPCS re-scan) with AI assistance, and the phpcbf auto-fix output was reviewed before committing. All changes were reviewed by me before submission.

Wraps $_REQUEST and $_SERVER values with wp_unslash() before
sanitization in acf_request_args(), acf_request_arg(), and
acf_get_current_url(), addressing
WordPress.Security.ValidatedSanitizedInput.MissingUnslash. Also
applies phpcbf auto-fixes for minor WPCS formatting violations.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props alkesh7.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Replaces an inconsistent :text() CSS pseudo-class combo with the
hasText locator option already used by the neighboring
restorePostType() helper for the same row-selection task.
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.

1 participant