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

SNOW-1677211: Password with double quote character causes Okta authenticator to fail #1901

Open
ehclark opened this issue Sep 23, 2024 · 1 comment
Assignees
Labels
bug status-triage Issue is under initial triage

Comments

@ehclark
Copy link

ehclark commented Sep 23, 2024

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of JDBC driver are you using? 3.14.4 (but a code review shows this bug still exists in the current master branch)

  2. What operating system and processor architecture are you using? MacOS amd64

  3. What version of Java are you using? Temurin 11

  4. What did you do?

package net.snowflake.client;

import java.sql.Connection;
import java.util.Properties;
import net.snowflake.client.jdbc.SnowflakeDriver;

public class Ping {
    public static void main(String[] args) throws Exception {
        Properties props = new Properties();
        props.setProperty("USER", "***");
        props.setProperty("AUTHENTICATOR", "https://***.okta.com/");
        props.setProperty("PASSWORD", "This\"ismypassword");
        props.setProperty("DB", "***");
        props.setProperty("SCHEMA", "***");
        SnowflakeDriver driver = new SnowflakeDriver();
        try (Connection conn = driver.connect("jdbc:snowflake://***.snowflakecomputing.com", props)) {
            conn.createStatement().executeQuery("SELECT CURRENT_USER()");
        }
    }
}
  1. What did you expect to see?
    Expectation is that the program will connect and execute the query successfully. Instead the following error is emitted:
Sep 23, 2024 8:33:19 AM net.snowflake.client.jdbc.RestRequest execute
SEVERE: Error response: HTTP Response code: 400, request: POST https://partnershealthcare.okta.com/api/v1/authn HTTP/1.1
Sep 23, 2024 8:33:19 AM net.snowflake.client.core.HttpUtil executeRequestInternal
SEVERE: Error executing request: POST https://partnershealthcare.okta.com/api/v1/authn HTTP/1.1
Sep 23, 2024 8:33:19 AM net.snowflake.client.jdbc.SnowflakeUtil logResponseDetails
SEVERE: Response status line reason: Bad Request
Sep 23, 2024 8:33:19 AM net.snowflake.client.jdbc.SnowflakeUtil logResponseDetails
SEVERE: Response content: {"errorCode":"E0000003","errorSummary":"The request body was not well-formed.","errorLink":"E0000003","errorId":"oaehNi0IwQeQNSFpm0TonOSjg","errorCauses":[]}
[WARNING] 
net.snowflake.client.jdbc.SnowflakeSQLException: JDBC driver encountered communication error. Message: HTTP status=400.
    at net.snowflake.client.core.HttpUtil.executeRequestInternal (HttpUtil.java:775)
    at net.snowflake.client.core.HttpUtil.executeRequestWithoutCookies (HttpUtil.java:564)
    at net.snowflake.client.core.SessionUtil.federatedFlowStep3 (SessionUtil.java:1192)
    at net.snowflake.client.core.SessionUtil.getSamlResponseUsingOkta (SessionUtil.java:1355)
    at net.snowflake.client.core.SessionUtil.newSession (SessionUtil.java:392)
    at net.snowflake.client.core.SessionUtil.openSession (SessionUtil.java:298)
    at net.snowflake.client.core.SFSession.open (SFSession.java:524)
    at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initialize (DefaultSFConnectionHandler.java:112)
    at net.snowflake.client.jdbc.DefaultSFConnectionHandler.initializeConnection (DefaultSFConnectionHandler.java:85)
    at net.snowflake.client.jdbc.SnowflakeConnectionV1.initConnectionWithImpl (SnowflakeConnectionV1.java:116)
    at net.snowflake.client.jdbc.SnowflakeConnectionV1.<init> (SnowflakeConnectionV1.java:96)
    at net.snowflake.client.jdbc.SnowflakeDriver.connect (SnowflakeDriver.java:206)
    at net.snowflake.client.Ping.main (Ping.java:16)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:279)
    at java.lang.Thread.run (Thread.java:829)
[INFO] --------------------------------------

The underlying cause is that in SessionUtil.federatedFlowStep3 the JSON payload sent to Okta endpoint is not properly escaped.

@ehclark ehclark added the bug label Sep 23, 2024
@github-actions github-actions bot changed the title Password with double quote character causes Okta authenticator to fail SNOW-1677211: Password with double quote character causes Okta authenticator to fail Sep 23, 2024
@sfc-gh-wfateem sfc-gh-wfateem self-assigned this Sep 25, 2024
@sfc-gh-wfateem
Copy link
Collaborator

Hi @ehclark,

Thanks for reporting the issue. We'll take a look into it.

Yes, it looks like we need to escape both the " and \ characters if they exist in the password.

@sfc-gh-wfateem sfc-gh-wfateem added the status-triage Issue is under initial triage label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status-triage Issue is under initial triage
Projects
None yet
Development

No branches or pull requests

2 participants