Skip to content
Changes

Reference

okta · Sep 24, 2026

What this change means

Regex changed, Capture groups changed, Credential parts changed, Pairing logic changed, How the credential is sent changed. Changes how the detector verifies or what it treats as the credential.

Field changes
FieldBeforeAfter
Regex patternsBefore: \b[a-z0-9-]{1,40}\.okta(?:preview|-emea){0,1}\.com\b, \b00[a-zA-Z0-9_-]{40}\b
After: (?:^|[^a-zA-Z0-9_-])([a-zA-Z0-9_-]{40,64})(?:[^a-zA-Z0-9_-]|$), \b[a-z0-9-]{1,40}\.okta(?:preview|-emea){0,1}\.com\b, \b00[a-zA-Z0-9_-]{40}\… show all
(?:^|[^a-zA-Z0-9_-])([a-zA-Z0-9_-]{40,64})(?:[^a-zA-Z0-9_-]|$), \b[a-z0-9-]{1,40}\.okta(?:preview|-emea){0,1}\.com\b, \b00[a-zA-Z0-9_-]{40}\b, \b0oa[a-zA-Z0-9]{17}\b
Credential partsBefore: domain, tokenAfter: domain, token, client_id, client_secret
How the credential is sentBefore: credential is sent in the Authorization header; scheme is not Bearer/token in sourceAfter: clientID is used as the username and secret is used as the password
pkg/detectors/okta/okta.go+134−2View file
@@ -20,12 +20,18 @@ type Scanner struct {
2020
2121// Ensure the Scanner satisfies the interface at compile time.
2222var _ detectors.Detector = (*Scanner)(nil)
23added: var _ detectors.CustomResultsCleaner = (*Scanner)(nil)
2324
2425var (
2526 defaultClient = detectors.DetectorHttpClientWithNoLocalAddresses
2627 domainPat = regexp.MustCompile(`\b[a-z0-9-]{1,40}\.okta(?:preview|-emea){0,1}\.com\b`)
2728 tokenPat = regexp.MustCompile(`\b00[a-zA-Z0-9_-]{40}\b`)
28removed: // TODO: Oauth client secrets
29added:
30added: // Okta app/client IDs: "0oa" + 17 base62 characters.
31added: oauthClientIDPat = regexp.MustCompile(`\b0oa[a-zA-Z0-9]{17}\b`)
32added: // Delimiters consume a char instead of using \b, since \b breaks on secrets
33added: // starting/ending in '-' (a non-word char that's also part of the charset).
34added: oauthClientSecretPat = regexp.MustCompile(detectors.PrefixRegex([]string{"client_secret", "clientsecret", "client-secret"}) + `(?:^|[^a-zA-Z0-9_-])([a-zA-Z0-9_-]{40,64})(?:[^a-zA-Z0-9_-]|$)`)
2935)
3036
3137// Keywords are used for efficiently pre-filtering chunks.
@@ -38,7 +44,10 @@ func (s Scanner) Keywords() []string {
3844func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) {
3945 dataStr := string(data)
4046
41removed: var uniqueTokens, uniqueDomains = make(map[string]struct{}), make(map[string]struct{})
47added: uniqueTokens := make(map[string]struct{})
48added: uniqueDomains := make(map[string]struct{})
49added: uniqueClientIDs := make(map[string]struct{})
50added: uniqueClientSecrets := make(map[string]struct{})
4251
4352 for _, matches := range tokenPat.FindAllStringSubmatch(dataStr, -1) {
4453 uniqueTokens[matches[0]] = struct{}{}
@@ -48,11 +57,20 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
4857 uniqueDomains[matches[0]] = struct{}{}
4958 }
5059
60added: for _, matches := range oauthClientIDPat.FindAllStringSubmatch(dataStr, -1) {
61added: uniqueClientIDs[matches[0]] = struct{}{}
62added: }
63added:
64added: for _, matches := range oauthClientSecretPat.FindAllStringSubmatch(dataStr, -1) {
65added: uniqueClientSecrets[matches[1]] = struct{}{}
66added: }
67added:
5168 for token := range uniqueTokens {
5269 for domain := range uniqueDomains {
5370 s1 := detectors.Result{
5471 DetectorType: detector_typepb.DetectorType_Okta,
5572 Raw: []byte(token),
73added: Redacted: fmt.Sprintf("%s:%s...%s", domain, token[:4], token[len(token)-4:]),
5674 SecretParts: map[string]string{
5775 "domain": domain,
5876 "token": token,
@@ -75,6 +93,37 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
7593 }
7694 }
7795
96added: for clientID := range uniqueClientIDs {
97added: for clientSecret := range uniqueClientSecrets {
98added: for domain := range uniqueDomains {
99added: s2 := detectors.Result{
100added: DetectorType: detector_typepb.DetectorType_Okta,
101added: Raw: []byte(clientSecret),
102added: Redacted: fmt.Sprintf("%s:%s", domain, clientID),
103added: SecretParts: map[string]string{
104added: "domain": domain,
105added: "client_id": clientID,
106added: "client_secret": clientSecret,
107added: },
108added: RawV2: []byte(fmt.Sprintf("%s:%s:%s", domain, clientID, clientSecret)),
109added: }
110added:
111added: if verify {
112added: client := s.client
113added: if client == nil {
114added: client = defaultClient
115added: }
116added:
117added: isVerified, verificationErr := verifyOktaOAuthClientCredentials(ctx, client, domain, clientID, clientSecret)
118added: s2.Verified = isVerified
119added: s2.SetVerificationError(verificationErr)
120added: }
121added:
122added: results = append(results, s2)
123added: }
124added: }
125added: }
126added:
78127 return
79128}
@@ -111,6 +160,89 @@ func verifyOktaToken(ctx context.Context, client *http.Client, domain, token str
111160 }
112161}
113162
163added: func verifyOktaOAuthClientCredentials(ctx context.Context, client *http.Client, domain, clientID, clientSecret string) (bool, error) {
164added: // curl -v -X POST \
165added: // -H "Accept: application/json" \
166added: // -H "Content-Type: application/x-www-form-urlencoded" \
167added: // -u "clientID:clientSecret" \
168added: // -d "grant_type=client_credentials" \
169added: // "https://subdomain.okta.com/oauth2/default/v1/token"
170added:
171added: const body = "grant_type=client_credentials"
172added:
173added: url := fmt.Sprintf("https://%s/oauth2/default/v1/token", domain)
174added: req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, strings.NewReader(body))
175added: if err != nil {
176added: return false, err
177added: }
178added: req.SetBasicAuth(clientID, clientSecret)
179added: req.Header.Set("Accept", "application/json")
180added: req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
181added:
182added: resp, err := client.Do(req)
183added: if err != nil {
184added: return false, err
185added: }
186added: defer func() { _ = resp.Body.Close() }()
187added:
188added: switch resp.StatusCode {
189added: case http.StatusOK:
190added: respBody, err := io.ReadAll(resp.Body)
191added: if err != nil {
192added: return false, err
193added: }
194added: return strings.Contains(string(respBody), "\"access_token\""), nil
195added: case http.StatusBadRequest:
196added: respBody, err := io.ReadAll(resp.Body)
197added: if err != nil {
198added: return false, err
199added: }
200added: // Okta authenticates the client before grant-type checks, so "unauthorized_client" still confirms the secret.
201added: if strings.Contains(string(respBody), "unauthorized_client") {
202added: return true, nil
203added: }
204added: if strings.Contains(string(respBody), "invalid_client") {
205added: return false, nil
206added: }
207added: // Other 400s (e.g. invalid_scope) say nothing about the secret; surface as an error.
208added: return false, fmt.Errorf("response body missing expected keyword")
209added: case http.StatusUnauthorized:
210added: return false, nil
211added: default:
212added: return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
213added: }
214added: }
215added:
216added: // CleanResults keeps the best (preferably verified) result per distinct secret
217added: // identity (Redacted), rather than collapsing unrelated SSWS and OAuth findings
218added: // down to a single arbitrary result the way detectors.CleanResults would.
219added: func (s Scanner) CleanResults(results []detectors.Result, _ bool) []detectors.Result {
220added: if len(results) == 0 {
221added: return results
222added: }
223added:
224added: byIdentity := make(map[string]detectors.Result, len(results))
225added: for _, r := range results {
226added: if r.Verified {
227added: byIdentity[r.Redacted] = r
228added: continue
229added: }
230added: if _, exists := byIdentity[r.Redacted]; !exists {
231added: byIdentity[r.Redacted] = r
232added: }
233added: }
234added:
235added: cleaned := make([]detectors.Result, 0, len(byIdentity))
236added: for _, r := range byIdentity {
237added: cleaned = append(cleaned, r)
238added: }
239added: return cleaned
240added: }
241added:
242added: func (s Scanner) ShouldCleanResultsIrrespectiveOfConfiguration() bool {
243added: return false
244added: }
245added:
114246func (s Scanner) Type() detector_typepb.DetectorType {
115247 return detector_typepb.DetectorType_Okta
116248}