Skip to content

[Bug][GitHub] A short token causes a panic, and then the connection list returns 500 #9446

Todo

Description

@henry-rystic

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

When a GitHub token has a known prefix but is too short, saving the connection causes a panic.

Cause:

  • sanitizeToken in backend/plugins/github/models/connection.go checks only tokenLen >= prefixLen (line 334).
  • Then it reads token[prefixLen+showPrefixLen : prefixLen+showPrefixLen+hiddenLen] (line 336).
  • This index is out of range when a classic token (ghp_, gho_, ghs_, ghr_, ghu_) has fewer than 32 characters, or when a github_pat_ token has fewer than 85 characters.
  • ModelApiHelper.Post saves the row (model_api_helper.go:72) before it calls Sanitize (line 76). So the connection is saved, even though the request fails.
  • Every later read calls Sanitize on this row and panics. GET /plugins/github/connections returns 500 for all GitHub connections until the row is deleted.

What do you expect to happen

  • A token that is too short is rejected with a clear error, or it is masked without a panic.
  • When the request fails, nothing is saved.
  • One bad connection does not stop the connection list from loading.

How to reproduce

Tested with the image apache/devlake:main_261124_0230_52d63a1 and MySQL 8.4.

  1. Send POST /plugins/github/connections with {"name":"short","endpoint":"https://api.github.com/","authMethod":"AccessToken","token":"ghp_short"}. Result: 500. The log shows panic recovered: runtime error: slice bounds out of range [:32] with length 9 at connection.go:336.
  2. The row is in the _tool_github_connections table.
  3. Send GET /plugins/github/connections. Result: 500, with the same panic. This also happens when a valid connection exists. GET /plugins/github/connections/<valid id> returns 200.
  4. Send DELETE /plugins/github/connections/<short id>. The row is deleted, but the result is 500. After this, the list returns 200 again.

A github_pat_ token with 30 characters gives the same result.

Anything else

It happens every time. A user can cause it by copying only part of a token. After that, the GitHub connections page does not load.

Possible fix: check tokenLen >= prefixLen+showPrefixLen+hiddenLen before the slice.

Version

main (52d63a1)

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. changed the title [-][Bug][GitHub] A short token panics on save, and the saved connection then breaks the connections list[/-] [+][Bug][GitHub] A short token causes a panic, and then the connection list returns 500[/+] on Nov 25, 2026
  2. added a commit that references this issue on Nov 25, 2026
    c1ca289
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ Proxy