Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SageMaker CreatePresignedDomainUrlCommandInput doesn't respect case sensitive UserProfileName parameter #6514

Closed
3 of 4 tasks
ericpapaluca opened this issue Sep 25, 2024 · 4 comments
Assignees
Labels
bug This issue is a bug. closed-for-staleness p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Comments

@ericpapaluca
Copy link

Checkboxes for prior research

Describe the bug

When using the SageMaker SDK with the CreatePresignedDomainUrlCommand, case sensitivity is not respected in the UserProfileName parameter. This causes the command to fail when the username is not entirely lowercase.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

"@aws-sdk/client-sagemaker": "3.658.0"

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

node -v v18.19.1

Reproduction Steps

Given a SageMaker domain with domainId d-12345 and a user named PowerUser, execute the following:


const client = new SageMakerClient();

const input: CreatePresignedDomainUrlCommandInput = {
    DomainId: "d-12345", 
    UserProfileName: "PowerUser", 
    SessionExpirationDurationInSeconds: 28800,
};


const command = new CreatePresignedDomainUrlCommand(input);
const response = await client.send(command); 

Observed Behavior

Due to my client's security posture and usage of permission's boundaries, the error I receive is the following:

<guid>    ERROR   Invoke Error    {"errorType":"AccessDeniedException","errorMessage":"User: <myRoleWithCorrectPermissions> is not authorized to perform: sagemaker:CreatePresignedDomainUrl on resource: arn:aws:sagemaker:us-east-1:ACCOUNT_NUMBER:user-profile/d-12345/poweruser because no permissions boundary allows the sagemaker:CreatePresignedDomainUrl action","name":"AccessDeniedException","$fault":"client","$metadata":{"httpStatusCode":400,"requestId":"foo","attempts":1,"totalRetryDelay":0},"__type":"AccessDeniedException"

This is the same error as the user not being found, looking further at the resource ARN of:
arn:aws:sagemaker:us-east-1:ACCOUNT_NUMBER:user-profile/d-12345/poweruser
We can see the PascalCase userProfileName in the parameters is changed to lowercase, causing the resource to be invalid.

I repeated this with a new username of test, all lowercase and the exact same code in the generation was successful.

Expected Behavior

A presigned URL is returned for the user PowerUser

Possible Solution

UserProfileName parameter is not respecting the case of the input

Additional Information/Context

No response

@ericpapaluca ericpapaluca added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 25, 2024
@zshzbh zshzbh self-assigned this Sep 26, 2024
@zshzbh
Copy link
Contributor

zshzbh commented Sep 30, 2024

Hey @ericpapaluca ,

Thanks for the feedback!

I'm using @aws-sdk/client-sagemaker": "^3.658.0 and node version v18.19.1 and I didn't have this issue.

The code I have :

import {SageMakerClient,CreatePresignedDomainUrlCommand } from"@aws-sdk/client-sagemaker"
const client = new SageMakerClient({region: "us-east-1"});

const input = {
    DomainId: "d-xxxxx", 
    UserProfileName: "PowerUse", 
    SessionExpirationDurationInSeconds: 28800,
};


const command = new CreatePresignedDomainUrlCommand(input);
const response = await client.send(command); 
console.log(response)

The result I have :

{
  '$metadata': {
    httpStatusCode: 200,
    requestId: 'XXXX-b284-48d7-930c-48e627fc71b3',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  AuthorizedUrl: 'hxxxxxxx'

I got the 200 OK result.

I intentionally delete an r and use UserProfileName: "PowerUse", , then I get the following error
ResourceNotFound: UserProfile [arn:aws:sagemaker:us-east-1:471112623206:user-profile/d-neeam48ovzvf/PowerUse] does not exist

I can't reproduce this issue and the sdk does show the uppercase PowerUse here.

@zshzbh
Copy link
Contributor

zshzbh commented Sep 30, 2024

I'd like to suggest

  1. remove node modules as well as aws pkgs and reinstall them
  2. update node version&sdk version
  3. rebuild the app

If the issue persists, please add the following code to the app to get request headers and we can check from there:

client.middlewareStack.add(next => async (args) => {
    console.log(args.request)
    const response = await next(args);
    console.log(response);
    return response;
   }, {step: 'finalizeRequest'}) 

Thanks!
Maggie

@zshzbh zshzbh added p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 30, 2024
Copy link

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Oct 11, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. closed-for-staleness p2 This is a standard priority issue response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants