WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@kashifkhan0771
Copy link
Contributor

Description:

This Pull request fixes github issue #3575
Screenshot from 2025-01-01 14-05-59

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@kashifkhan0771 kashifkhan0771 requested a review from a team as a code owner January 1, 2025 09:42
@kashifkhan0771 kashifkhan0771 linked an issue Jan 1, 2025 that may be closed by this pull request

return isVerified, err
// if response contain the forbiddenError message it means the token is active but does not have the right scope for this API call
if strings.Contains(fmt.Sprintf("%v", responseBody), forbiddenError) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case the token is Active and does not have the org:<> scope the API returns 403 with a specific error message. In case token is removed the API return 401

func TestSentryToken_FromChunk(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors3")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

detectors3 vault limit is full

wantVerificationErr: true,
},
{
name: "found, good key but wrong scope",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed some tests which are not necessary.

@kashifkhan0771 kashifkhan0771 requested a review from a team as a code owner January 1, 2025 10:13
@kashifkhan0771 kashifkhan0771 requested a review from rgmz January 2, 2025 06:38
@kashifkhan0771 kashifkhan0771 self-assigned this Jan 10, 2025

var (
// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
keyPat = regexp.MustCompile(`\b(sntryu_[a-f0-9]{64})\b`)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is missing sntrys_ tokens mentioned in #3575.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is the Sentry ORG token pattern. Organization auth tokens have a limited set of scopes and lack access to many APIs. These tokens are primarily used for sentry-cli operations; you can find more details here. If needed, I’d recommend creating a separate detector specifically for ORG tokens.

Copy link
Contributor

Choose a reason for hiding this comment

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

Regardless, it was explicitly mentioned in #3575. Either the issue should be re-opened until it's added, or it should be updated with a rationale why only one was added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the docs: Organization Auth Tokens can be used in many places to interact with Sentry programatically. For example, they can be used for sentry-cli, bundler plugins or similar uses cases.

I will add this in issue comments as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't really say why it isn't worth detecting, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can detect them but my point is how do we verify them? The organization auth token are used in sentry-cli for mainly two purposes:

  • Uploading source maps: The SolidStart guide shows an example of using an organization auth token to upload source maps using the sentrySolidStartVite plugin.
  • CI/CD environments: Organization auth tokens are recommended for use in CI/CD environments, as mentioned in the SolidStart guide.

Note: This information is provided by Sentry AI Docs

Copy link

@dsekz dsekz Mar 4, 2025

Choose a reason for hiding this comment

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

I should clarify that Sentry Organization Auth Tokens could still potentially expose sensitive information if misused. I'm not too sure how to verify it, I mean it can be verified with a simple request to the sentry API, but I don't know if it will be a detailed verification. Add this token for sure, it can have access to sensitive informations and write permission.

Some companies are using it and they can expose it accidentally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dsekz I mentioned earlier in the issue that for sntrys tokens a separate detector would be required and some additional effort to know how we can verify them. I created a ticket in our backlog for a new detector.

@kashifkhan0771 kashifkhan0771 merged commit 39d2453 into trufflesecurity:main Jan 20, 2025
13 checks passed
@kashifkhan0771 kashifkhan0771 deleted the fix/github-issue-3575 branch January 20, 2025 10:31
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.

Sentry Auth Token not detected

4 participants