aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Route53Domains.TransferDomainToAnotherAwsAccount generates paswords with single quotes and backticks

Open scottcrespo opened this issue 6 years ago • 12 comments

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug

route53domains transfer-domain-to-another-aws-account returns passwords with special characters that are difficult, if not impossible, to escape in bash. Call it luck of the draw, but I had a password generated that contained single quotes and backticks.

Escaping those characters with backslashes resulted in authentication failure when calling route53domains accept-domain-transfer-from-another-aws-account.

Only solution was to leverage --cli-input-json file://path/to/file.json

This issue could cause intermittent failure of bash scripts for transferring domains when the script attempts to call route53domains accept-domain-transfer-from-another-aws-account and cli param --password. Or in my case, about an hour of headache.

SDK version number

aws-cli/1.18.69 
Python/3.6.9 
Linux/5.3.0-62-generic 
botocore/1.16.19

Platform/OS/Hardware/Device OS: Linux Mint 19.3 Tricia Hardware: amd64 Device: Dell M4600

To Reproduce (observed behavior)

Step 1: call aws route53domains transfer-domain-to-another-aws-account --domain-name <domain name> --account-id <account id>

If you receive password with single quotes or backticks....

Step 2: aws route53domains accept-domain-transfer-from-another-aws-account --domain-name <domain name> --password <password with backslashes to escape>

Then password will fail with: An error occurred (InvalidInput) when calling the AcceptDomainTransferFromAnotherAwsAccount operation: Password is incorrect.

Expected behavior

  1. CLI/API should not generate passwords with characters that will break the CLI. Dollar signs may also be an issue for BASH users.

AND/OR

  1. Prominent warnings in documentation

Logs/output Get full traceback and error logs by adding --debug to the command.

Additional context Add any other context about the problem here.

scottcrespo avatar Jul 28 '20 17:07 scottcrespo

Hi @scottcrespo, I can see how that would be frustrating, especially passwords with single quotes (usually the delimiter to use in the console for literal interpretation of a string). This would have to be handled by the service team. I agree at a minimum, this should be clearly documented.

kdaily avatar Jul 30 '20 21:07 kdaily

@kdaily Thanks for the quick response. Please let me know if you need any more information or action on my end.

scottcrespo avatar Aug 02 '20 15:08 scottcrespo

Hi @scottcrespo , another option (and more secure) would be to write the password to a file and then use it as the parameter to --password. You could use a JMESPath query for the aws route53domains transfer-domain-to-another-aws-account (or, pipe the output to a tool like jq) to get the password field to a file (say /tmp/password.txt). Then you can do:

aws route53domains accept-domain-transfer-from-another-aws-account --domain-name <domain name> --password file:///tmp/password.txt

This would keep the password out of the console and out of an environment variable as well. Does this solution help you out? The documentation could still be improved to make users aware of the character set available for passwords.

kdaily avatar Aug 03 '20 13:08 kdaily

@kdaily

Clever solutions! They would be great additions to the documentation to help anyone else that encounters the issue. I got around using a similar approach: I wrote the parameters to a file and used --cli-input-json file://path/to/file.json to accept the domain transfer.

IMHO, a simpler and less error-prone solution (for the long term) might be for the API to return a random alphanumeric string; for example, a random SHA1 or SHA256 hash. When writing a script or doing a copy+paste operation, I don't think users would mind working with a longer password that has a limited and "safer" character set.

scottcrespo avatar Aug 03 '20 16:08 scottcrespo

Good suggestion, @scottcrespo. Here are the docs for using the --query option, which works with all AWS CLI commands. It Isn't included with every service action because it's a client-side operation:

https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output.html#cli-usage-output-filter

kdaily avatar Aug 03 '20 16:08 kdaily

Hi @scottcrespo, I've passed this on to the API team, so going to close this out here as it isn't specific to the AWS CLI. Thanks again for your feedback and suggestions!

kdaily avatar Aug 10 '20 18:08 kdaily

I definitely see a bug there with aws-cli/2.4.4 Python/3.9.9 Darwin/20.6.0 source/x86_64 prompt/off

Here's the response I've got from route53domains transfer-domain-to-another-aws-account command:

{
    "OperationId": "2bc2995d-c8f1-4c1f-b24e-9676f30fd3ac",
    "Password": "xaY7y3w?Ni{V\"E"
}
  1. I tried different variants of escaping it in the command line.
  2. I tried putting it in the environment variable.
  3. I tried the aws route53domains accept-domain-transfer-from-another-aws-account --cli-input-json file://params.json way.

No mater what I do, the response is the same: An error occurred (InvalidInput) when calling the AcceptDomainTransferFromAnotherAwsAccount operation: Password is incorrect.

This made me think that some characters are already escaped in the original output I got. And YES! The password is not xaY7y3w?Ni{V\"E as you may think, it's actually xaY7y3w?Ni{V"E - you need to guess it. What a pain!

Aldekein avatar Dec 03 '21 06:12 Aldekein

Hi everyone,

Just here to add that 2 years after the initial bug was reported, this issue persist. in fact it has gotten worse. One has to initiate and cancel a domain transfer several times before getting an acceptable password. Is there a fix to this?

cmartinio avatar Jul 09 '22 02:07 cmartinio

@fxgx99 See the above reply from @kdaily about putting the password in a file and then using --password file://pw.txt to load it in the CLI. Not perfect and difficult to automate, but you're probably not doing this often.

ehcloninger avatar Aug 07 '22 21:08 ehcloninger

Hi @scottcrespo , another option (and more secure) would be to write the password to a file and then use it as the parameter to --password. You could use a JMESPath query for the aws route53domains transfer-domain-to-another-aws-account (or, pipe the output to a tool like jq) to get the password field to a file (say /tmp/password.txt). Then you can do:

aws route53domains accept-domain-transfer-from-another-aws-account --domain-name <domain name> --password file:///tmp/password.txt

This would keep the password out of the console and out of an environment variable as well. Does this solution help you out? The documentation could still be improved to make users aware of the character set available for passwords.

this method worked for me.

abhinavbom avatar Aug 14 '22 05:08 abhinavbom

For anyone else going crazy with this:

Instead of the suggested --password path-to-pw-file which doesn't work for me (who knows why), use the other suggestion of --cli-input-json path-to-file, but don't paste the whole json that you got from the original transfer request (from the "source" account), just have json with only the password in:

{ "Password": "querty" }

and make sure the file path is of this format (on Windows anyway) --cli-input-json file://C:/Users/andy/temp.json.

andavies avatar Nov 16 '22 16:11 andavies

Hi, I still get the error message:

Error parsing parameter 'cli-input-json': Invalid JSON received.

I type this here in my terminal commands: aws route53domains accept-domain-transfer-from-another-aws-account --domain-name example.com --region us-east-1 --cli-input-json /Users/aguy/Downloads/temp.json

My json looks like this:

{
"Password": "string"
}

I am on Mac OS version 13.0.1

Vintotan avatar Nov 28 '22 12:11 Vintotan