The Java check needs to be hardened. Unlike the other language SDKs, which check that the scheme string is exactly HTTPS and fails otherwise, the Java check only confirms that it is "not HTTP" (and assumes anything else is "HTTPS"). That, along with the fact that the setter doesn't do any checking, there could be a way for a malformed authority host url to get through.
Comparing to other languages, this check:
|
if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) { |
|
return Mono.error(new RuntimeException("token credentials require a URL using the HTTPS protocol scheme")); |
|
} |
Should be something like the following (unless we have other non-HTTP supported schemes beyond HTTPS in Java): if (!context.getHttpRequest().getUrl().getProtocol().equals("https")
Introduced in this PR (the intent of which I gather is to only allow HTTPS): #6543
cc @joshfree, @billwert
The Java check needs to be hardened. Unlike the other language SDKs, which check that the scheme string is exactly HTTPS and fails otherwise, the Java check only confirms that it is "not HTTP" (and assumes anything else is "HTTPS"). That, along with the fact that the setter doesn't do any checking, there could be a way for a malformed authority host url to get through.
Comparing to other languages, this check:
azure-sdk-for-java/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java
Lines 93 to 95 in 0fbfd34
Should be something like the following (unless we have other non-HTTP supported schemes beyond HTTPS in Java):
if (!context.getHttpRequest().getUrl().getProtocol().equals("https")Introduced in this PR (the intent of which I gather is to only allow HTTPS): #6543
cc @joshfree, @billwert