Fix security vulnerabilities SQLi and 2x Broken Access Control - #2356
Open
the-hercules wants to merge 3 commits into
Open
Fix security vulnerabilities SQLi and 2x Broken Access Control#2356the-hercules wants to merge 3 commits into
the-hercules wants to merge 3 commits into
Conversation
Contributor
|
Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:
The error may be temporary. If the error persists, please contact a human (commit-ID: 987efec). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the 3 security vulnerabilities. Each fix is its own commit with before/after verification.
Issues fixed
1. Unauthenticated SQL Injection (CVSS 9.3) —
7b0e50fc2On any public
[rtmedia_gallery]page,?rtmedia_shortcode=1merges$_REQUESTinto the media query args. The
compareoperator for array-shaped filters(e.g.
id[compare]) was interpolated into the SQLWHEREclause after onlyesc_sql(), which does not protect an operator position — allowing arbitrarySQL. Verified time-based (
SLEEP) and boolean-blind extraction ofwp_users.user_passover unauthenticated HTTP.Fix: validate
compareagainst a fixed allowlist of SQL operators(shared helper
RTDBModel::sanitize_sql_compare_operator(), applied to everysink:
RTMediaModel::get(),get_counts(), themeta_querybranch, and thebase
RTDBModel::get()); escape the value in theIS NOTbranch; rejectarray-shaped values from the
$_REQUESTmerge so public params are scalar-only.2. Broken Access Control — rtMedia privacy bypass via JSON/Mobile API —
88e2d1115rtMedia's privacy filter is only registered when
RTMediaQueryis constructedduring normal page rendering. The JSON/mobile API never constructs it, so
rtmedia_get_media_detailsreturned any media by numeric ID — includinganother user's Private media with a direct download URL — to any authenticated
API caller. IDs are small sequential integers, making site-wide enumeration
of private media trivial.
Fix: explicit authorization check (
rtmedia_api_current_user_can_view_media())mirroring
RTMediaQuery::privacy_filter()'s tiers (admin / public / logged-in /owner / friends) before returning media; response is scoped to only the
requested media id (a sibling media/comments in the same activity can no
longer leak); fixed two related bugs in the comments lookup found during the fix
(wrong
get_comments()arg key, uninitialized array).3. Broken Access Control — arbitrary album/author/group injection on upload —
987efeca4The upload pipeline trusted client-supplied
album_id,media_author,context/context_idfrom raw$_POST; the only gate,has_album_permissions(),was a permanent stub returning
true. Any authenticated user could injectmedia into another user's (including private) album, attribute media to
another user, or upload into a BuddyPress group they were not a member of —
via the front-end upload flow, the comment-media flow, and the JSON API.
Fix: implemented real album/context/group authorization (owner, global
album, group membership via the existing
rtm_can_user_upload_in_groupfilter, or admin); force
media_authorto the acting user; clampprivacyto the valid set; re-authorize at the final upload boundary so later
reassignment (e.g. via
comment_media_activity_id) can't bypass the check;applied the same checks to the JSON API's base64 upload path.
Verification
before the fix (exploit confirmed), then re-verified after
Not included in this PR
649 warnings) — mostly pre-existing legacy issues unrelated to these 3
vulnerabilities;
final resubmission commit.