Skip to content

fix(slack-app): escape channel and workspace names and encode reflected uid parameter (#14876) - #14877

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
shuoYun114:fix/slack-app-xss-and-uid-reflection
Sep 19, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
shuoYun114:fix/slack-app-xss-and-uid-reflection

Conversation

@shuoYun114

@shuoYun114 shuoYun114 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Multiple routes on omi-slack-app rendered client-controlled or Slack-supplied inputs directly into HTML without output encoding or URL quoting:

  1. GET / (authenticated settings page) — channel and workspace name XSS:

    • channel['id'] and channel['name'] were interpolated into <option> tags using raw strings:
      channel_options += f'<option value="{channel["id"]}" {selected_attr}>{privacy} {channel["name"]}</option>'
      A channel name or ID containing markup (such as </option><script>alert(1)</script> or C123" onfocus="alert(1)) executed arbitrary script inside the plugin origin.
    • team_name was rendered unescaped in Connected to <span class="username">{team_name}</span>.
    • In inline JavaScript (refreshChannels(), logoutUser()), {uid} was interpolated into fetch URLs without URL-safe percent-encoding.
  2. GET /auth/callback (OAuth redirect) — reflected XSS & breakout:

    • On success: team_name was interpolated into Your Slack workspace <strong>{team_name}</strong> is now linked without escaping.
    • On failure: the Try again link interpolated raw uid into <a href="/auth?uid={uid}">.
    • The callback handler now accepts error: str = Query(None) and properly escapes error messages when authorization fails or is denied.
  3. GET / (unauthenticated connect page):

    • auth_url = f"/auth?uid={uid}" reflected raw uid into <a href="{auth_url}">. A uid of "><script>alert(1)</script> broke out of the attribute; query separators like & or # corrupted the flow.

Fix

Following the pattern established by #14581 (google calendar app) and #13658:

  • html.escape() applied to team_name, channel['id'], channel['name'], and OAuth error.
  • quote(uid, safe="") applied to all uid reflections in URL/href and JavaScript contexts.

Verification

New hermetic regression suite: plugins/omi-slack-app/test_settings_page.py (stdlib only, zero network or external dependencies):

  • 7/7 passed in 0.005s:
    1. test_channel_names_and_ids_are_escaped_in_picker: proves markup and quotes in channel IDs/names are escaped (&lt;script&gt;, &quot;).
    2. test_team_name_is_escaped_in_settings_page: proves workspace name cannot inject HTML elements.
    3. test_team_name_is_escaped_in_oauth_callback: proves workspace name is safe in callback success HTML.
    4. test_oauth_callback_error_is_escaped: proves OAuth error strings are escaped.
    5. test_unauthenticated_uid_is_url_encoded: proves breakout characters are percent-encoded in auth link.
    6. test_uid_query_separators_do_not_corrupt_link: proves & and # do not split or corrupt parameters.
    7. test_ordinary_inputs_render_normally: control test verifying standard user flows render unmodified.
  • Red → Green: 5 of the 7 tests failed against original code; all 7 now pass cleanly.
  • Existing test suites regression check:
    • test_channel_resolution.py: 9/9 passed.
    • test_segments.py: 8/8 passed.
    • test_slack_search.py: 5/5 passed.
  • Registered as slack-app-settings-page-encoding-tests in .github/checks-manifest.yaml (triggers on plugins/omi-slack-app/**). Manifest validated (239 checks, zero duplicates).

Failure-Class: none

Fixes #14876


Payout Destination

  • USDT (TRC20): TGKmfSUmt2dggErAo8BicaCoXhkMwLetxV
  • BTC: 1NkUnv23H65ZYJn64pseAcWRA6sJitxh2f
  • PayPal: [email protected]

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified end to end - thank you for the clean fix and for shipping a hermetic regression suite with it.

What I checked in plugins/omi-slack-app/main.py:

  • The settings page now escapes channel id/name in the loop and team_name in the "Connected to" header. The old code interpolated these raw; rendering the base code confirms the XSS was real (a uid of "><script>alert(1)</script> reflects straight out of the href attribute).
  • uid is percent-encoded via quote(uid, safe="") at every reflection: the unauthenticated /auth link, the authenticated inline-JS fetch URLs (/update-channel, /refresh-channels, /logout, and the redirect back to /?uid=), both OAuth callback links, and the /test interface value attribute. The /test client JS now also wraps uid in encodeURIComponent for its fetches.
  • auth_callback() now accepts the OAuth error parameter and renders it escaped with a 400 page instead of ignoring it, and team_name falls back to "Unknown" on explicit None (the old dict.get default only covered a missing key, not a None value).
  • added across the HTML responses.

Verification: ran plugins/omi-slack-app/test_settings_page.py in isolation against both this branch (12/12 pass) and the pre-fix main.py (9 failures + 1 error, including the raw breakout string) - so the tests genuinely detect the vulnerability rather than passing vacuously. The manifest entry slack-app-settings-page-encoding-tests is registered with the standard triggers/lanes, and CI is green.

Two non-blocking notes for the maintainer pass:

  1. The only behavioral additions beyond encoding are the new OAuth error page in auth_callback (400 response) and the charset metas - sensible, but it is a new response path on an auth-adjacent surface.
  2. Other Slack-derived text I sampled outside this PR's scope (e.g. channel names in the /webhook list response) flows through JSONResponse, which JSON-encodes rather than renders HTML - safe as-is.

The bounty proposal in #14876 stays with the maintainers as a separate decision; this review covers the code only.

🤖 Automated review on behalf of the maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces python positive-signal Automation verified a genuine fix/quality contribution labels Sep 19, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Real XSS/attribute-breakout fix for #14876 (html.escape + URL quoting), comprehensive test suite, CI fully green; scores 4/5 on confidence gate. Winner over duplicate #14878 which has a malformed checks-manifest edit and no CI run.

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

Labels

positive-signal Automation verified a genuine fix/quality contribution python security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty proposal] security: omi-slack-app reflects raw channel/workspace names into HTML (XSS) + uid attribute breakout ( proposed)

4 participants