Skip to content

fix(api): prevent update_news auth bypass from broad rescue - #3729

Open
jmthomas wants to merge 2 commits into
mainfrom
fix/update-news-auth-bypass
Open

fix(api): prevent update_news auth bypass from broad rescue#3729
jmthomas wants to merge 2 commits into
mainfrom
fix/update-news-auth-bypass

Conversation

@jmthomas

Copy link
Copy Markdown
Member

The method-level rescue Exception swallowed the AuthError raised by authorize, so unauthenticated JSON-RPC callers got 200 OK and an anonymous write to the openc3_news Redis key. Authorize now runs outside the rescued region and the rescue is narrowed to StandardError.

Also disables the User Menu Refresh button for non-admins, which previously wiped the feed on Enterprise, and adds the missing Extract/Authorization requires to three specs that could not load standalone.

🤖 Generated with Claude Code

The method-level `rescue Exception` swallowed the AuthError raised by
authorize, so unauthenticated JSON-RPC callers got 200 OK and an
anonymous write to the openc3_news Redis key. Authorize now runs outside
the rescued region and the rescue is narrowed to StandardError.

Also disables the User Menu Refresh button for non-admins, which
previously wiped the feed silently on Enterprise, and adds the missing
Extract/Authorization requires to three specs that could not load
standalone.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jmthomas
jmthomas requested review from clayandgen and ryan-pratt and a lite review from Copilot August 19, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an authorization bypass in the Settings API’s update_news endpoint where a broad rescue Exception previously swallowed AuthError, allowing unauthenticated callers to receive 200 OK and trigger a write to the news feed key. It also aligns the frontend UI with the backend permission requirement and stabilizes specs by adding missing requires.

Changes:

  • Moved authorize(...) outside the rescued region in update_news and narrowed the rescue to StandardError so auth failures propagate correctly.
  • Disabled the “Refresh” button for the news feed in the User Menu when the user is not an admin.
  • Added missing Extract / Authorization requires and introduced targeted specs for update_news auth and connectivity failures.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
openc3/spec/microservices/decom_microservice_spec.rb Adds missing Extract require to allow the spec to load standalone.
openc3/spec/api/stash_api_spec.rb Adds missing Extract / Authorization requires for standalone spec loading.
openc3/spec/api/settings_api_spec.rb Adds missing requires and new coverage asserting update_news auth failure does not write the feed.
openc3/lib/openc3/api/settings_api.rb Fixes the auth-bypass by moving authorization outside the rescue and narrowing the rescued exception type.
openc3-cosmos-init/plugins/packages/openc3-vue-common/src/tools/base/UserMenu.vue Disables the news refresh button for non-admins and adds a test selector attribute.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.06%. Comparing base (3af6dff) to head (c521418).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
openc3/lib/openc3/api/settings_api.rb 50.00% 3 Missing ⚠️
...ages/openc3-vue-common/src/tools/base/UserMenu.vue 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3729      +/-   ##
==========================================
+ Coverage   79.58%   80.06%   +0.47%     
==========================================
  Files         885      885              
  Lines       65382    65383       +1     
  Branches     2543     2592      +49     
==========================================
+ Hits        52035    52347     +312     
+ Misses      12674    12374     -300     
+ Partials      673      662      -11     
Flag Coverage Δ
frontend 66.12% <0.00%> (+2.49%) ⬆️
python 81.87% <ø> (+<0.01%) ⬆️
ruby-api 82.53% <ø> (+0.04%) ⬆️
ruby-backend 84.46% <50.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@clayandgen clayandgen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The periodic microservice might have this same issue? Let me know what you think:

NewsModel.news_error("Error contacting OpenC3 news feed. #{e.message})")

Comment thread openc3/spec/api/settings_api_spec.rb
@jmthomas
jmthomas requested a review from clayandgen August 21, 2026 00:17
@sonarqubecloud

Copy link
Copy Markdown

@jmthomas

Copy link
Copy Markdown
Member Author

The periodic microservice might have this same issue? Let me know what you think:

NewsModel.news_error("Error contacting OpenC3 news feed. #{e.message})")

Sort of. This is an internal microservice with no permissions checks. However it did have the broad rescue Exception and extra paren ) which was fixed in the other location.

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.

3 participants