Skip to content

Retranscode only media items, with an hourly limit below Editor - #2385

Closed
subodhr258 wants to merge 2 commits into
mainfrom
fix/retranscode-attachment-only
Closed

subodhr258 wants to merge 2 commits into
mainfrom
fix/retranscode-attachment-only

Conversation

@subodhr258

Copy link
Copy Markdown
Collaborator

What and why

2.10.0 opened the retranscode route (POST /godam/v1/transcoding/retranscode, also used by godam/retranscode-media) to anyone who can edit the item, so an Author can redo their own uploads. Two gaps from the security check of the release:

  • The route checked only edit_post on the ID, so a Contributor could send their own draft post, which is not media. On godam-multisite.local a Contributor's POST with their draft's ID passed the permission check (it stopped later only because the site is local). The route now also requires an attachment.
  • Each retranscode uses the site's GoDAM plan, and an Author could loop over their uploads. Users below Editor can now start 10 an hour (filter rtgodam_retranscode_hourly_limit, 0 turns it off). Editors and above, who use the bulk Retranscoding page, are not limited.

Patch-level: not a data leak, and the ability itself already refused non-media IDs. Listed under "Can follow in a patch" on https://github.com/rtCamp/godam-plugin-wp/issues/106.

Where to look

The parts a human reviewer should spend their time on. Everything else is mechanical: the test and the regenerated POT.

  1. Permission (inc/classes/rest-api/class-transcoding.php:802-818)
    if ( current_user_can( 'edit_others_posts' ) ) {
        return true;
    }
    ...
    $can = 'attachment' === get_post_type( $attachment_id ) && current_user_can( 'edit_post', $attachment_id );
    Check: the type check sits inside the attachment-lookup hook pair, so central media resolves on the right site.
  2. Hourly limit (inc/classes/rest-api/class-transcoding.php:829-870, called at the top of retranscode_media())
    $key  = 'rtgodam_retranscode_count_' . get_current_user_id();
    ...
    if ( $used['count'] >= $limit ) {
        return false;
    }
    ++$used['count'];
    set_transient( $key, $used, max( 1, $used['until'] - $now ) );
    Check: a fixed one-hour window per user, counted per request that passes the permission check (including ones the route later skips, such as local sites). The refusal is a 429 with reason: rate_limited, which the ability turns into an error with that message.

UI evidence

No UI change: the route answers 403 or 429 where it used to run; Editors (who use the Retranscoding page) see no difference. Live check on godam-multisite.local:

Request develop this branch
Contributor, POST .../retranscode with own draft post ID passed the permission check 403
Author, own video, 11 calls in a row through MCP all 11 ran 11th: "You have started the most retranscodes allowed in an hour..."
Editor, any video ran ran

How to test

  1. As a Contributor with an Application Password, POST /wp-json/godam/v1/transcoding/retranscode with {"id": <own draft post ID>}: expect 403.
  2. As an Author, call godam-retranscode-media on one of your videos 11 times: the 11th answers with the hourly-limit message.
  3. As an Editor, retranscode from Media > GoDAM Tools > Retranscoding: no limit.
  4. vendor/bin/phpunit --filter RetranscodePermissionTest.

Risk

risk: low because it only narrows who can retranscode what; Editors and the bulk page are unchanged.

The retranscode route let anyone who can edit an ID retranscode it, so a
Contributor could send their own draft post, which is not media. It now
also requires an attachment. Users below Editor can start 10 retranscodes
an hour (filter rtgodam_retranscode_hourly_limit), so an Author looping
over their uploads cannot burn the site's GoDAM plan. Editors and above,
who use the bulk Retranscoding page, are not limited.
@subodhr258 subodhr258 added the risk: low QA automation only (Dependabot fixes, copy, CSS) label Nov 17, 2026
@github-actions

Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
13 0 13

⚠️ Warnings (13)

📁 readme.txt (1 warning)
📍 Line 🔖 Check 💬 Message
0 mismatched_plugin_name Plugin name "GoDAM - Video Hosting for LMS & Online Courses" is different from the name declared in plugin header "GoDAM".
📁 assets/build/pages/video-editor.min.js (1 warning)
📍 Line 🔖 Check 💬 Message
2 react_removed_api This file calls "ReactDOM.findDOMNode", which was removed in React 19 and stops working once WordPress upgrades React. Use a ref on the element instead.
📁 assets/build/css/main.css (1 warning)
📍 Line 🔖 Check 💬 Message
0 EnqueuedStylesScope This style is being loaded in all contexts.
📁 assets/src/libs/analytics.min.js (5 warnings)
📍 Line 🔖 Check 💬 Message
0 EnqueuedScriptsScope This script is being loaded in all frontend contexts.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/2026/11/17/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
📁 assets/build/js/main.min.js (5 warnings)
📍 Line 🔖 Check 💬 Message
0 EnqueuedScriptsScope This script is being loaded in all frontend contexts.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/2026/11/17/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@subodhr258
subodhr258 changed the base branch from develop to main November 17, 2026 10:03
@subodhr258

Copy link
Copy Markdown
Collaborator Author

Folded into #2384 (one GoDAM security PR for 2.10.0): the retranscode fix is commit b78b444 there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low QA automation only (Dependabot fixes, copy, CSS)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant