Skip to content

Unsanitised endpoints string formatting #306

@cedws

Description

@cedws

Describe the bug?

There are various methods in the SDK which take a string parameter and format an endpoint URL. Take this method for example:

// Fetches a user from your Okta organization.
func (m *UserResource) GetUser(ctx context.Context, userId string) (*User, *Response, error) {
url := fmt.Sprintf("/api/v1/users/%v", userId)
rq := m.client.CloneRequestExecutor()
req, err := rq.WithAccept("application/json").WithContentType("application/json").NewRequest("GET", url, nil)
if err != nil {
return nil, nil, err
}
var user *User
resp, err := rq.Do(ctx, req, &user)
if err != nil {
return nil, resp, err
}
return user, resp, nil
}

A username is taken as a parameter and appended to /api/v1/users/. This could be an issue because the username is not sanitised. If the attacker controls this input it would be possible to call another endpoint by passing something such as fakeuser/grants, fakeusers/groups, or any other endpoint that accepts GET requests. This principle could be used to perform other operations like POST/PUT requests.

This could be dangerous if a consumer of the SDK is not aware that they need to pre-sanitise. In the real world, we can imagine an internal web page for looking up Okta users. A form sends a username to the backend which is passed into GetUser(). Somebody able to access the web page might be able to send crafted inputs to potentially obtain information they shouldn't be able to or perform administrative actions.

What is expected to happen?

The SDK should convey that consumers are expected to sanitise strings to prevent manipulation of endpoint URLs.

What is the actual behavior?

The SDK is vulnerable to manipulation of endpoint URLs via unsanitised input.

Reproduction Steps?

Proof of concept code:

package main

import (
        "context"
        "fmt"
        "github.com/okta/okta-sdk-golang/v2/okta"
)

func main() {
        _, oktaClient, _ := okta.NewClient(
                context.TODO(),
                okta.WithOrgUrl(OKTA_ORG),
                okta.WithToken(OKTA_TOKEN),
        )

        user, resp, err := oktaClient.User.GetUser(ctx, "fakeuser/groups")
        fmt.Printf("%+v %+v %+v\n", user, resp, err)
}

Additional Information?

No response

Golang Version

N/A

SDK Version

v2.12.1

OS version

No response

Activity

laura-rodriguez

laura-rodriguez commented on May 30, 2022

@laura-rodriguez
Contributor

Hi @cedws,

Thanks for reporting this issue. Someone from our team will review it soon.

cc @MikeMondragon-okta

self-assigned this
on Jun 1, 2022
github-actions

github-actions commented on Jun 16, 2022

@github-actions

This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the stale label.

removed their assignment
on Aug 16, 2022
self-assigned this
on Mar 17, 2025
dhiwakar-okta

dhiwakar-okta commented on Nov 14, 2025

@dhiwakar-okta

@cedws , In the latest version of the SDK i.e. v6.0.0, we use url.PathEscape() which should go some way towards addressing this vulnerability. If you still believe this to be an issue, please create a new one as this has gotten quite old now.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @monde@laura-rodriguez@cedws@aditya-okta@dhiwakar-okta

      Issue actions

        Unsanitised endpoints string formatting · Issue #306 · okta/okta-sdk-golang