Is it insecure to send a password in a `curl` command?
Here’s an example request we can make to the GitHub API:
curl 'https://api.github.com/authorizations' --user "USERNAME"
This will prompt for the account password, to continue:
Enter host password for user 'USERNAME':
If we don’t want to get the prompt, we can provide the password at the same time as the username:
curl 'https://api.github.com/authorizations' --user "USERNAME:PASSWORD"
But is this method less secure? Does curl
send all the data at once, or does it first setup a secure connection, and only then send the USERNAME
and PASSWORD
?
macosx curl
add a comment |
Here’s an example request we can make to the GitHub API:
curl 'https://api.github.com/authorizations' --user "USERNAME"
This will prompt for the account password, to continue:
Enter host password for user 'USERNAME':
If we don’t want to get the prompt, we can provide the password at the same time as the username:
curl 'https://api.github.com/authorizations' --user "USERNAME:PASSWORD"
But is this method less secure? Does curl
send all the data at once, or does it first setup a secure connection, and only then send the USERNAME
and PASSWORD
?
macosx curl
add a comment |
Here’s an example request we can make to the GitHub API:
curl 'https://api.github.com/authorizations' --user "USERNAME"
This will prompt for the account password, to continue:
Enter host password for user 'USERNAME':
If we don’t want to get the prompt, we can provide the password at the same time as the username:
curl 'https://api.github.com/authorizations' --user "USERNAME:PASSWORD"
But is this method less secure? Does curl
send all the data at once, or does it first setup a secure connection, and only then send the USERNAME
and PASSWORD
?
macosx curl
Here’s an example request we can make to the GitHub API:
curl 'https://api.github.com/authorizations' --user "USERNAME"
This will prompt for the account password, to continue:
Enter host password for user 'USERNAME':
If we don’t want to get the prompt, we can provide the password at the same time as the username:
curl 'https://api.github.com/authorizations' --user "USERNAME:PASSWORD"
But is this method less secure? Does curl
send all the data at once, or does it first setup a secure connection, and only then send the USERNAME
and PASSWORD
?
macosx curl
macosx curl
asked 19 hours ago
user137369user137369
1755
1755
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Regarding the connection there's no difference: the TLS is negotiated first and the HTTP request is secured by the TLS.
Locally this might be less secure, because:
- The password gets saved to the command history (
~/.bash_history
) as a part of the command, but this can be avoided by adding a space in front of the command before running it. - On a shared system, it will usually be visible to others in
ps
,top
and such, or by reading/proc/$pid/cmdline
, for as long as the command is running. - Storing the password unsecured in a script might pose a security risk, depending on where the script itself is stored.
16
And if on a shared system, it will usually be visible to others inps
andtop
and such, or by reading/proc/$pid/cmdline
– dave_thompson_085
14 hours ago
1
Excellent addition, Dave!
– Esa Jokinen
14 hours ago
1
Then you must keep the script in a safe place. I'd recommend700
permissions.
– Esa Jokinen
11 hours ago
2
to solve the issue with.bash_history
you could just prepend a space in front of your command. This way it doesn't get saved to history. (further info over here: unix.stackexchange.com/questions/115917/… )
– Anticom
9 hours ago
4
This doesn't solve the/proc/${pid}/cmdline
issue (e.g., it showing up inps
output). If there are multiple users on a system, this is a great way to accidentally disclose a password.
– Stephen Touset
6 hours ago
|
show 3 more comments
No, it is not if you use https
. When you use HTTPS
your complete transaction will be encrypted.
But as @Esa mentioned it is insecure locally. You can inspect how your data is transferred with tcpdump
, tshark
or Wireshark
like following,
TCPDUMP
[root@arif]# tcpdump -i eth0 -n src host 192.168.1.1 and dst port 443 -XX
TSHARK
[root@arif]# tshark -O tls -f "tcp port 443" -f "ip src 192.168.1.1" -x
add a comment |
The best way to protect from local users is to use a ".netrc" file; the curl man page should have details and at least, if I recall, an example.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "162"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsecurity.stackexchange.com%2fquestions%2f205479%2fis-it-insecure-to-send-a-password-in-a-curl-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Regarding the connection there's no difference: the TLS is negotiated first and the HTTP request is secured by the TLS.
Locally this might be less secure, because:
- The password gets saved to the command history (
~/.bash_history
) as a part of the command, but this can be avoided by adding a space in front of the command before running it. - On a shared system, it will usually be visible to others in
ps
,top
and such, or by reading/proc/$pid/cmdline
, for as long as the command is running. - Storing the password unsecured in a script might pose a security risk, depending on where the script itself is stored.
16
And if on a shared system, it will usually be visible to others inps
andtop
and such, or by reading/proc/$pid/cmdline
– dave_thompson_085
14 hours ago
1
Excellent addition, Dave!
– Esa Jokinen
14 hours ago
1
Then you must keep the script in a safe place. I'd recommend700
permissions.
– Esa Jokinen
11 hours ago
2
to solve the issue with.bash_history
you could just prepend a space in front of your command. This way it doesn't get saved to history. (further info over here: unix.stackexchange.com/questions/115917/… )
– Anticom
9 hours ago
4
This doesn't solve the/proc/${pid}/cmdline
issue (e.g., it showing up inps
output). If there are multiple users on a system, this is a great way to accidentally disclose a password.
– Stephen Touset
6 hours ago
|
show 3 more comments
Regarding the connection there's no difference: the TLS is negotiated first and the HTTP request is secured by the TLS.
Locally this might be less secure, because:
- The password gets saved to the command history (
~/.bash_history
) as a part of the command, but this can be avoided by adding a space in front of the command before running it. - On a shared system, it will usually be visible to others in
ps
,top
and such, or by reading/proc/$pid/cmdline
, for as long as the command is running. - Storing the password unsecured in a script might pose a security risk, depending on where the script itself is stored.
16
And if on a shared system, it will usually be visible to others inps
andtop
and such, or by reading/proc/$pid/cmdline
– dave_thompson_085
14 hours ago
1
Excellent addition, Dave!
– Esa Jokinen
14 hours ago
1
Then you must keep the script in a safe place. I'd recommend700
permissions.
– Esa Jokinen
11 hours ago
2
to solve the issue with.bash_history
you could just prepend a space in front of your command. This way it doesn't get saved to history. (further info over here: unix.stackexchange.com/questions/115917/… )
– Anticom
9 hours ago
4
This doesn't solve the/proc/${pid}/cmdline
issue (e.g., it showing up inps
output). If there are multiple users on a system, this is a great way to accidentally disclose a password.
– Stephen Touset
6 hours ago
|
show 3 more comments
Regarding the connection there's no difference: the TLS is negotiated first and the HTTP request is secured by the TLS.
Locally this might be less secure, because:
- The password gets saved to the command history (
~/.bash_history
) as a part of the command, but this can be avoided by adding a space in front of the command before running it. - On a shared system, it will usually be visible to others in
ps
,top
and such, or by reading/proc/$pid/cmdline
, for as long as the command is running. - Storing the password unsecured in a script might pose a security risk, depending on where the script itself is stored.
Regarding the connection there's no difference: the TLS is negotiated first and the HTTP request is secured by the TLS.
Locally this might be less secure, because:
- The password gets saved to the command history (
~/.bash_history
) as a part of the command, but this can be avoided by adding a space in front of the command before running it. - On a shared system, it will usually be visible to others in
ps
,top
and such, or by reading/proc/$pid/cmdline
, for as long as the command is running. - Storing the password unsecured in a script might pose a security risk, depending on where the script itself is stored.
edited 2 hours ago
answered 18 hours ago
Esa JokinenEsa Jokinen
2,754919
2,754919
16
And if on a shared system, it will usually be visible to others inps
andtop
and such, or by reading/proc/$pid/cmdline
– dave_thompson_085
14 hours ago
1
Excellent addition, Dave!
– Esa Jokinen
14 hours ago
1
Then you must keep the script in a safe place. I'd recommend700
permissions.
– Esa Jokinen
11 hours ago
2
to solve the issue with.bash_history
you could just prepend a space in front of your command. This way it doesn't get saved to history. (further info over here: unix.stackexchange.com/questions/115917/… )
– Anticom
9 hours ago
4
This doesn't solve the/proc/${pid}/cmdline
issue (e.g., it showing up inps
output). If there are multiple users on a system, this is a great way to accidentally disclose a password.
– Stephen Touset
6 hours ago
|
show 3 more comments
16
And if on a shared system, it will usually be visible to others inps
andtop
and such, or by reading/proc/$pid/cmdline
– dave_thompson_085
14 hours ago
1
Excellent addition, Dave!
– Esa Jokinen
14 hours ago
1
Then you must keep the script in a safe place. I'd recommend700
permissions.
– Esa Jokinen
11 hours ago
2
to solve the issue with.bash_history
you could just prepend a space in front of your command. This way it doesn't get saved to history. (further info over here: unix.stackexchange.com/questions/115917/… )
– Anticom
9 hours ago
4
This doesn't solve the/proc/${pid}/cmdline
issue (e.g., it showing up inps
output). If there are multiple users on a system, this is a great way to accidentally disclose a password.
– Stephen Touset
6 hours ago
16
16
And if on a shared system, it will usually be visible to others in
ps
and top
and such, or by reading /proc/$pid/cmdline
– dave_thompson_085
14 hours ago
And if on a shared system, it will usually be visible to others in
ps
and top
and such, or by reading /proc/$pid/cmdline
– dave_thompson_085
14 hours ago
1
1
Excellent addition, Dave!
– Esa Jokinen
14 hours ago
Excellent addition, Dave!
– Esa Jokinen
14 hours ago
1
1
Then you must keep the script in a safe place. I'd recommend
700
permissions.– Esa Jokinen
11 hours ago
Then you must keep the script in a safe place. I'd recommend
700
permissions.– Esa Jokinen
11 hours ago
2
2
to solve the issue with
.bash_history
you could just prepend a space in front of your command. This way it doesn't get saved to history. (further info over here: unix.stackexchange.com/questions/115917/… )– Anticom
9 hours ago
to solve the issue with
.bash_history
you could just prepend a space in front of your command. This way it doesn't get saved to history. (further info over here: unix.stackexchange.com/questions/115917/… )– Anticom
9 hours ago
4
4
This doesn't solve the
/proc/${pid}/cmdline
issue (e.g., it showing up in ps
output). If there are multiple users on a system, this is a great way to accidentally disclose a password.– Stephen Touset
6 hours ago
This doesn't solve the
/proc/${pid}/cmdline
issue (e.g., it showing up in ps
output). If there are multiple users on a system, this is a great way to accidentally disclose a password.– Stephen Touset
6 hours ago
|
show 3 more comments
No, it is not if you use https
. When you use HTTPS
your complete transaction will be encrypted.
But as @Esa mentioned it is insecure locally. You can inspect how your data is transferred with tcpdump
, tshark
or Wireshark
like following,
TCPDUMP
[root@arif]# tcpdump -i eth0 -n src host 192.168.1.1 and dst port 443 -XX
TSHARK
[root@arif]# tshark -O tls -f "tcp port 443" -f "ip src 192.168.1.1" -x
add a comment |
No, it is not if you use https
. When you use HTTPS
your complete transaction will be encrypted.
But as @Esa mentioned it is insecure locally. You can inspect how your data is transferred with tcpdump
, tshark
or Wireshark
like following,
TCPDUMP
[root@arif]# tcpdump -i eth0 -n src host 192.168.1.1 and dst port 443 -XX
TSHARK
[root@arif]# tshark -O tls -f "tcp port 443" -f "ip src 192.168.1.1" -x
add a comment |
No, it is not if you use https
. When you use HTTPS
your complete transaction will be encrypted.
But as @Esa mentioned it is insecure locally. You can inspect how your data is transferred with tcpdump
, tshark
or Wireshark
like following,
TCPDUMP
[root@arif]# tcpdump -i eth0 -n src host 192.168.1.1 and dst port 443 -XX
TSHARK
[root@arif]# tshark -O tls -f "tcp port 443" -f "ip src 192.168.1.1" -x
No, it is not if you use https
. When you use HTTPS
your complete transaction will be encrypted.
But as @Esa mentioned it is insecure locally. You can inspect how your data is transferred with tcpdump
, tshark
or Wireshark
like following,
TCPDUMP
[root@arif]# tcpdump -i eth0 -n src host 192.168.1.1 and dst port 443 -XX
TSHARK
[root@arif]# tshark -O tls -f "tcp port 443" -f "ip src 192.168.1.1" -x
edited 15 hours ago
answered 15 hours ago
MuhammadMuhammad
705618
705618
add a comment |
add a comment |
The best way to protect from local users is to use a ".netrc" file; the curl man page should have details and at least, if I recall, an example.
add a comment |
The best way to protect from local users is to use a ".netrc" file; the curl man page should have details and at least, if I recall, an example.
add a comment |
The best way to protect from local users is to use a ".netrc" file; the curl man page should have details and at least, if I recall, an example.
The best way to protect from local users is to use a ".netrc" file; the curl man page should have details and at least, if I recall, an example.
answered 6 hours ago
sitaramsitaram
592
592
add a comment |
add a comment |
Thanks for contributing an answer to Information Security Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsecurity.stackexchange.com%2fquestions%2f205479%2fis-it-insecure-to-send-a-password-in-a-curl-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown