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

fix(iot-dev): Add an upper limit to SAS token expiry time values #1755

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public final class ClientConfiguration

private static final long DEFAULT_OPERATION_TIMEOUT = 4 * 60 * 1000; //4 minutes

private static final long MAX_SAS_TOKEN_EXPIRY_TIME_SECONDS = 10 * 365 * 24 * 60 * 60; //10 years

private boolean useWebsocket;

@Getter
Expand Down Expand Up @@ -244,6 +246,13 @@ private void setClientOptionValues(ClientOptions clientOptions)
throw new IllegalArgumentException("ClientOption sasTokenExpiryTime must be greater than 0");
}

if (clientOptions.getSasTokenExpiryTime() >= MAX_SAS_TOKEN_EXPIRY_TIME_SECONDS)
{
// Higher values cause overflows that result in the SDK repeatedly renewing SAS tokens
// and are generally a security risk
throw new IllegalArgumentException("ClientOption sasTokenExpiryTime must be less than 10 years");
}

this.getSasTokenAuthentication().setTokenValidSecs(clientOptions.getSasTokenExpiryTime());
}

Expand Down
Loading