Is using 'echo' to display attacker-controlled data on the terminal dangerous?Is it possible to use the Linux “echo” command maliciously?Why does printf() vulnerability require 4-bytes of junk data? - “Hacking: The Art of Exploitation”iOS Unicode Notification BugHow dangerous is the remote Jeep Cherokee attack?How does text that is displayed with cat end up trying to execute in the Linux terminal?Is the unauthorized deletion of data considered a breach of integrity or availability?Using data URIs to perform XSS in anchor tags - vulnerability?The requirements of gathering information data without any limits?Is it possible to get data from database server if you are on the application server?How secure is a serial/terminal/console server, from the serial side?In some situation can be dangerous to echo command (e.g. rm -rf *) using a script?
Fermat's statement about the ancients: How serious was he?
How did old MS-DOS games utilize various graphic cards?
Does the Long March-11 increase its thrust after clearing the launch tower?
Who are the Missing Members of this Noble Family?
Thread Pool C++ Implementation
Artificer Creativity
Has there been a multiethnic Star Trek character?
Is it legal for a bar bouncer to confiscate a fake ID
Check if three arrays contains the same element
How to trick the reader into thinking they're following a redshirt instead of the protagonist?
Someone whose aspirations exceed abilities or means
Why does Sin[b-a] simplify to -Sin[a-b]?
What ways have you found to get edits from non-LaTeX users?
Traversing Oceania: A Cryptic Journey
Can I utilise a baking stone to make crepes?
Why didn't Voldemort recognize that Dumbledore was affected by his curse?
Wooden cooking layout
Why 1,2 printed by a command in $() is not interpolated?
What aircraft was used as Air Force One for the flight between Southampton and Shannon?
ed command: Delete from line 1 until the first blank line
How is the excise border managed in Ireland?
bmatrix: how to align elements' subscripts?
Overlapping String-Blocks
Generate basis elements of the Steenrod algebra
Is using 'echo' to display attacker-controlled data on the terminal dangerous?
Is it possible to use the Linux “echo” command maliciously?Why does printf() vulnerability require 4-bytes of junk data? - “Hacking: The Art of Exploitation”iOS Unicode Notification BugHow dangerous is the remote Jeep Cherokee attack?How does text that is displayed with cat end up trying to execute in the Linux terminal?Is the unauthorized deletion of data considered a breach of integrity or availability?Using data URIs to perform XSS in anchor tags - vulnerability?The requirements of gathering information data without any limits?Is it possible to get data from database server if you are on the application server?How secure is a serial/terminal/console server, from the serial side?In some situation can be dangerous to echo command (e.g. rm -rf *) using a script?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Imagine the following code:
ATTACKERDATA="$(cat attackerControlledFile.txt)"
echo "$ATTACKERDATA"
An attacker can, through whatever arbitrary process, modify the contents of attackerControlledFile.txt to anything they desire. The content can be ASCII, UTF-8, Binary, etc. Anything is fine. The machine also assumes that it is infinitely fast, so even an extremely large file of multiple terrabytes would be read and printed immediately.
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
- This code only works in
bash - This code requires the output to be printed onto a specific terminal emulator
- Etc.
Everything else assumes a reasonably sane system. This means that answers such as "If echo is an attacker-controlled binary that's actually malware" does not count, as the existence of malware is not exactly "reasonably sane". Answers that would require a specific software or version of that software to be present do count, as long as that software was not made for the purpose of exploitation.
A similar question asks Is it possible to use the Linux “echo” command maliciously?, but the accepted answer is actually about a flaw in the design of a web application. Furthermore, it requires the attacker to be able to do redirects, which as far as I know, this construct cannot do.
vulnerability bash
add a comment |
Imagine the following code:
ATTACKERDATA="$(cat attackerControlledFile.txt)"
echo "$ATTACKERDATA"
An attacker can, through whatever arbitrary process, modify the contents of attackerControlledFile.txt to anything they desire. The content can be ASCII, UTF-8, Binary, etc. Anything is fine. The machine also assumes that it is infinitely fast, so even an extremely large file of multiple terrabytes would be read and printed immediately.
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
- This code only works in
bash - This code requires the output to be printed onto a specific terminal emulator
- Etc.
Everything else assumes a reasonably sane system. This means that answers such as "If echo is an attacker-controlled binary that's actually malware" does not count, as the existence of malware is not exactly "reasonably sane". Answers that would require a specific software or version of that software to be present do count, as long as that software was not made for the purpose of exploitation.
A similar question asks Is it possible to use the Linux “echo” command maliciously?, but the accepted answer is actually about a flaw in the design of a web application. Furthermore, it requires the attacker to be able to do redirects, which as far as I know, this construct cannot do.
vulnerability bash
what if it's a million bells? while not dangerous, it's certainly annoying...
– dandavis
3 hours ago
add a comment |
Imagine the following code:
ATTACKERDATA="$(cat attackerControlledFile.txt)"
echo "$ATTACKERDATA"
An attacker can, through whatever arbitrary process, modify the contents of attackerControlledFile.txt to anything they desire. The content can be ASCII, UTF-8, Binary, etc. Anything is fine. The machine also assumes that it is infinitely fast, so even an extremely large file of multiple terrabytes would be read and printed immediately.
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
- This code only works in
bash - This code requires the output to be printed onto a specific terminal emulator
- Etc.
Everything else assumes a reasonably sane system. This means that answers such as "If echo is an attacker-controlled binary that's actually malware" does not count, as the existence of malware is not exactly "reasonably sane". Answers that would require a specific software or version of that software to be present do count, as long as that software was not made for the purpose of exploitation.
A similar question asks Is it possible to use the Linux “echo” command maliciously?, but the accepted answer is actually about a flaw in the design of a web application. Furthermore, it requires the attacker to be able to do redirects, which as far as I know, this construct cannot do.
vulnerability bash
Imagine the following code:
ATTACKERDATA="$(cat attackerControlledFile.txt)"
echo "$ATTACKERDATA"
An attacker can, through whatever arbitrary process, modify the contents of attackerControlledFile.txt to anything they desire. The content can be ASCII, UTF-8, Binary, etc. Anything is fine. The machine also assumes that it is infinitely fast, so even an extremely large file of multiple terrabytes would be read and printed immediately.
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
- This code only works in
bash - This code requires the output to be printed onto a specific terminal emulator
- Etc.
Everything else assumes a reasonably sane system. This means that answers such as "If echo is an attacker-controlled binary that's actually malware" does not count, as the existence of malware is not exactly "reasonably sane". Answers that would require a specific software or version of that software to be present do count, as long as that software was not made for the purpose of exploitation.
A similar question asks Is it possible to use the Linux “echo” command maliciously?, but the accepted answer is actually about a flaw in the design of a web application. Furthermore, it requires the attacker to be able to do redirects, which as far as I know, this construct cannot do.
vulnerability bash
vulnerability bash
edited 8 hours ago
MechMK1
asked 9 hours ago
MechMK1MechMK1
3,06211033
3,06211033
what if it's a million bells? while not dangerous, it's certainly annoying...
– dandavis
3 hours ago
add a comment |
what if it's a million bells? while not dangerous, it's certainly annoying...
– dandavis
3 hours ago
what if it's a million bells? while not dangerous, it's certainly annoying...
– dandavis
3 hours ago
what if it's a million bells? while not dangerous, it's certainly annoying...
– dandavis
3 hours ago
add a comment |
3 Answers
3
active
oldest
votes
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
This code requires the output to be printed onto a specific terminal emulator
In fact, yes. Old terminals like vt100 have the ability to use ANSI escape sequences to do special things, like execute commands. The following site below documents this ability using a simple echo, like you describe.
https://www.proteansec.com/linux/blast-past-executing-code-terminal-emulators-via-escape-sequences/
The article is in depth with specific exploit instructions, but the general idea can be summarized from this excerpt from the site:
Dangerous Escape Sequences
Terminal emulators support multiple features as described below [8]:
Screen Dumping: a screen dump escape sequence will open arbitrary file and write the current content of the terminal into the file. Some terminal emulators will not write to existing files, but only to new files, while others will simply overwrite the file with the new contents. An attacker might use this feature to create a new backdoor PHP file in the DocumentRoot of the web server, which can later be used to execute arbitrary commands.
Window Title: an escape sequence exists for setting the window title, which will change the window title string. This feature can be used together with another escape sequence, which reads the current window title and prints it to the current command line. Since a carriage return character is prohibited in the window title, an attacker can store the command in a window title and print it to the current command line, but it would still require a user to press enter in order to execute it. There are techniques for making the command invisible, like setting the text color to the same color as the background, which increases the changes of user pressing the enter key.
Command Execution: some terminal emulators could even allow execution of the command directly by using an escape sequence.
2
+1 for the interesting info, however all examples in the above link make use ofecho -ewhich OP is not using
– CaffeineAddiction
8 hours ago
2
@CaffeineAddiction I don't know that the exploit requires -e to be used, and guess that echoing the binary contents of a file would also echo the special characters too. I'm also not familiar with all versions of echo written for every OS. The author is using the gnu echo, other versions may operate differently and allow the same escaped characters without the -e option.
– Steve Sether
8 hours ago
1
if you re-read the article, every example the author uses makes use ofecho -eorprintf... the exploit simply will not work with out it ...echo -estates the following in its man pagesenable interpretation of backslash escapes... so pretty much the whole point of the article
– CaffeineAddiction
1 hour ago
@CaffeineAddiction:echosans-ecan still echo any arbitrary bytes (except NUL) just by having those bytes passed to it on the command line — say, because those bytes were in an attacker-controlled binary file read into a variable that was thenechoed.
– jwodder
31 mins ago
add a comment |
No, echo used in the example above is fine
Echo simply prints a string to the pipe stdout (default)
per: https://superuser.com/a/699500/527937
Pipes can't overflow. A pipe is just a buffer (a certain amount of
memory, most likely 64KB on a current system) between a producer and a
consumer. If the producer produces faster than the consumer consumes,
the producer is blocked (that means, the program will sleep) until the
consumer makes room in the buffer again by reading from it.
As a side note, if you have a large ammount of data in 1x line ... cat can hang and/or consume an enormous amount of system memory.
A DoS was the most likely too. I recall that I once displayed a binary file on my terminal, and when it finally finished, I got lots of command not found errors, which left me wondering if there was a way to abuse it.
– MechMK1
9 hours ago
these are most likly errors fromechoand not bash, eg it encountered a backslash command that is not recognized as an option
– CaffeineAddiction
9 hours ago
I can't seem to find a way to exploit this either. Too bad, that would have been cool to exploit.
– MechMK1
9 hours ago
thecatportion could most likly be exploited ... egecho '"ls' > attackerControlledFile.txt
– CaffeineAddiction
9 hours ago
Just outputs"lsfor me.
– MechMK1
8 hours ago
|
show 1 more comment
Does
echo "$(cat /etc/shadow)"
or
echo "$(mv test.txt test2.txt)"
Satisfy your requirement?
2
An attacker can modify the contents in the text file. I thought about command expansion, but as far as I know, command expansion occurs before cat even reads the file. Hence this approach does not work. I edited my question to clarify this.
– MechMK1
8 hours ago
@MechMK1 I see. I'll explore some more then.
– DarkMatter
8 hours ago
Sorry if I did not specify my requirements enough at first. I hope things are clear now. Sorry for any wasted effort
– MechMK1
8 hours ago
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%2f211419%2fis-using-echo-to-display-attacker-controlled-data-on-the-terminal-dangerous%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
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
This code requires the output to be printed onto a specific terminal emulator
In fact, yes. Old terminals like vt100 have the ability to use ANSI escape sequences to do special things, like execute commands. The following site below documents this ability using a simple echo, like you describe.
https://www.proteansec.com/linux/blast-past-executing-code-terminal-emulators-via-escape-sequences/
The article is in depth with specific exploit instructions, but the general idea can be summarized from this excerpt from the site:
Dangerous Escape Sequences
Terminal emulators support multiple features as described below [8]:
Screen Dumping: a screen dump escape sequence will open arbitrary file and write the current content of the terminal into the file. Some terminal emulators will not write to existing files, but only to new files, while others will simply overwrite the file with the new contents. An attacker might use this feature to create a new backdoor PHP file in the DocumentRoot of the web server, which can later be used to execute arbitrary commands.
Window Title: an escape sequence exists for setting the window title, which will change the window title string. This feature can be used together with another escape sequence, which reads the current window title and prints it to the current command line. Since a carriage return character is prohibited in the window title, an attacker can store the command in a window title and print it to the current command line, but it would still require a user to press enter in order to execute it. There are techniques for making the command invisible, like setting the text color to the same color as the background, which increases the changes of user pressing the enter key.
Command Execution: some terminal emulators could even allow execution of the command directly by using an escape sequence.
2
+1 for the interesting info, however all examples in the above link make use ofecho -ewhich OP is not using
– CaffeineAddiction
8 hours ago
2
@CaffeineAddiction I don't know that the exploit requires -e to be used, and guess that echoing the binary contents of a file would also echo the special characters too. I'm also not familiar with all versions of echo written for every OS. The author is using the gnu echo, other versions may operate differently and allow the same escaped characters without the -e option.
– Steve Sether
8 hours ago
1
if you re-read the article, every example the author uses makes use ofecho -eorprintf... the exploit simply will not work with out it ...echo -estates the following in its man pagesenable interpretation of backslash escapes... so pretty much the whole point of the article
– CaffeineAddiction
1 hour ago
@CaffeineAddiction:echosans-ecan still echo any arbitrary bytes (except NUL) just by having those bytes passed to it on the command line — say, because those bytes were in an attacker-controlled binary file read into a variable that was thenechoed.
– jwodder
31 mins ago
add a comment |
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
This code requires the output to be printed onto a specific terminal emulator
In fact, yes. Old terminals like vt100 have the ability to use ANSI escape sequences to do special things, like execute commands. The following site below documents this ability using a simple echo, like you describe.
https://www.proteansec.com/linux/blast-past-executing-code-terminal-emulators-via-escape-sequences/
The article is in depth with specific exploit instructions, but the general idea can be summarized from this excerpt from the site:
Dangerous Escape Sequences
Terminal emulators support multiple features as described below [8]:
Screen Dumping: a screen dump escape sequence will open arbitrary file and write the current content of the terminal into the file. Some terminal emulators will not write to existing files, but only to new files, while others will simply overwrite the file with the new contents. An attacker might use this feature to create a new backdoor PHP file in the DocumentRoot of the web server, which can later be used to execute arbitrary commands.
Window Title: an escape sequence exists for setting the window title, which will change the window title string. This feature can be used together with another escape sequence, which reads the current window title and prints it to the current command line. Since a carriage return character is prohibited in the window title, an attacker can store the command in a window title and print it to the current command line, but it would still require a user to press enter in order to execute it. There are techniques for making the command invisible, like setting the text color to the same color as the background, which increases the changes of user pressing the enter key.
Command Execution: some terminal emulators could even allow execution of the command directly by using an escape sequence.
2
+1 for the interesting info, however all examples in the above link make use ofecho -ewhich OP is not using
– CaffeineAddiction
8 hours ago
2
@CaffeineAddiction I don't know that the exploit requires -e to be used, and guess that echoing the binary contents of a file would also echo the special characters too. I'm also not familiar with all versions of echo written for every OS. The author is using the gnu echo, other versions may operate differently and allow the same escaped characters without the -e option.
– Steve Sether
8 hours ago
1
if you re-read the article, every example the author uses makes use ofecho -eorprintf... the exploit simply will not work with out it ...echo -estates the following in its man pagesenable interpretation of backslash escapes... so pretty much the whole point of the article
– CaffeineAddiction
1 hour ago
@CaffeineAddiction:echosans-ecan still echo any arbitrary bytes (except NUL) just by having those bytes passed to it on the command line — say, because those bytes were in an attacker-controlled binary file read into a variable that was thenechoed.
– jwodder
31 mins ago
add a comment |
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
This code requires the output to be printed onto a specific terminal emulator
In fact, yes. Old terminals like vt100 have the ability to use ANSI escape sequences to do special things, like execute commands. The following site below documents this ability using a simple echo, like you describe.
https://www.proteansec.com/linux/blast-past-executing-code-terminal-emulators-via-escape-sequences/
The article is in depth with specific exploit instructions, but the general idea can be summarized from this excerpt from the site:
Dangerous Escape Sequences
Terminal emulators support multiple features as described below [8]:
Screen Dumping: a screen dump escape sequence will open arbitrary file and write the current content of the terminal into the file. Some terminal emulators will not write to existing files, but only to new files, while others will simply overwrite the file with the new contents. An attacker might use this feature to create a new backdoor PHP file in the DocumentRoot of the web server, which can later be used to execute arbitrary commands.
Window Title: an escape sequence exists for setting the window title, which will change the window title string. This feature can be used together with another escape sequence, which reads the current window title and prints it to the current command line. Since a carriage return character is prohibited in the window title, an attacker can store the command in a window title and print it to the current command line, but it would still require a user to press enter in order to execute it. There are techniques for making the command invisible, like setting the text color to the same color as the background, which increases the changes of user pressing the enter key.
Command Execution: some terminal emulators could even allow execution of the command directly by using an escape sequence.
Is it possible for an attacker, regardless of how unlikely it would be, to exploit this somehow by modifying the content of attackerControlledFile.txt? "Somehow" refers to things like:
This code requires the output to be printed onto a specific terminal emulator
In fact, yes. Old terminals like vt100 have the ability to use ANSI escape sequences to do special things, like execute commands. The following site below documents this ability using a simple echo, like you describe.
https://www.proteansec.com/linux/blast-past-executing-code-terminal-emulators-via-escape-sequences/
The article is in depth with specific exploit instructions, but the general idea can be summarized from this excerpt from the site:
Dangerous Escape Sequences
Terminal emulators support multiple features as described below [8]:
Screen Dumping: a screen dump escape sequence will open arbitrary file and write the current content of the terminal into the file. Some terminal emulators will not write to existing files, but only to new files, while others will simply overwrite the file with the new contents. An attacker might use this feature to create a new backdoor PHP file in the DocumentRoot of the web server, which can later be used to execute arbitrary commands.
Window Title: an escape sequence exists for setting the window title, which will change the window title string. This feature can be used together with another escape sequence, which reads the current window title and prints it to the current command line. Since a carriage return character is prohibited in the window title, an attacker can store the command in a window title and print it to the current command line, but it would still require a user to press enter in order to execute it. There are techniques for making the command invisible, like setting the text color to the same color as the background, which increases the changes of user pressing the enter key.
Command Execution: some terminal emulators could even allow execution of the command directly by using an escape sequence.
answered 8 hours ago
Steve SetherSteve Sether
17.7k63766
17.7k63766
2
+1 for the interesting info, however all examples in the above link make use ofecho -ewhich OP is not using
– CaffeineAddiction
8 hours ago
2
@CaffeineAddiction I don't know that the exploit requires -e to be used, and guess that echoing the binary contents of a file would also echo the special characters too. I'm also not familiar with all versions of echo written for every OS. The author is using the gnu echo, other versions may operate differently and allow the same escaped characters without the -e option.
– Steve Sether
8 hours ago
1
if you re-read the article, every example the author uses makes use ofecho -eorprintf... the exploit simply will not work with out it ...echo -estates the following in its man pagesenable interpretation of backslash escapes... so pretty much the whole point of the article
– CaffeineAddiction
1 hour ago
@CaffeineAddiction:echosans-ecan still echo any arbitrary bytes (except NUL) just by having those bytes passed to it on the command line — say, because those bytes were in an attacker-controlled binary file read into a variable that was thenechoed.
– jwodder
31 mins ago
add a comment |
2
+1 for the interesting info, however all examples in the above link make use ofecho -ewhich OP is not using
– CaffeineAddiction
8 hours ago
2
@CaffeineAddiction I don't know that the exploit requires -e to be used, and guess that echoing the binary contents of a file would also echo the special characters too. I'm also not familiar with all versions of echo written for every OS. The author is using the gnu echo, other versions may operate differently and allow the same escaped characters without the -e option.
– Steve Sether
8 hours ago
1
if you re-read the article, every example the author uses makes use ofecho -eorprintf... the exploit simply will not work with out it ...echo -estates the following in its man pagesenable interpretation of backslash escapes... so pretty much the whole point of the article
– CaffeineAddiction
1 hour ago
@CaffeineAddiction:echosans-ecan still echo any arbitrary bytes (except NUL) just by having those bytes passed to it on the command line — say, because those bytes were in an attacker-controlled binary file read into a variable that was thenechoed.
– jwodder
31 mins ago
2
2
+1 for the interesting info, however all examples in the above link make use of
echo -e which OP is not using– CaffeineAddiction
8 hours ago
+1 for the interesting info, however all examples in the above link make use of
echo -e which OP is not using– CaffeineAddiction
8 hours ago
2
2
@CaffeineAddiction I don't know that the exploit requires -e to be used, and guess that echoing the binary contents of a file would also echo the special characters too. I'm also not familiar with all versions of echo written for every OS. The author is using the gnu echo, other versions may operate differently and allow the same escaped characters without the -e option.
– Steve Sether
8 hours ago
@CaffeineAddiction I don't know that the exploit requires -e to be used, and guess that echoing the binary contents of a file would also echo the special characters too. I'm also not familiar with all versions of echo written for every OS. The author is using the gnu echo, other versions may operate differently and allow the same escaped characters without the -e option.
– Steve Sether
8 hours ago
1
1
if you re-read the article, every example the author uses makes use of
echo -e or printf ... the exploit simply will not work with out it ... echo -e states the following in its man pages enable interpretation of backslash escapes ... so pretty much the whole point of the article– CaffeineAddiction
1 hour ago
if you re-read the article, every example the author uses makes use of
echo -e or printf ... the exploit simply will not work with out it ... echo -e states the following in its man pages enable interpretation of backslash escapes ... so pretty much the whole point of the article– CaffeineAddiction
1 hour ago
@CaffeineAddiction:
echo sans -e can still echo any arbitrary bytes (except NUL) just by having those bytes passed to it on the command line — say, because those bytes were in an attacker-controlled binary file read into a variable that was then echoed.– jwodder
31 mins ago
@CaffeineAddiction:
echo sans -e can still echo any arbitrary bytes (except NUL) just by having those bytes passed to it on the command line — say, because those bytes were in an attacker-controlled binary file read into a variable that was then echoed.– jwodder
31 mins ago
add a comment |
No, echo used in the example above is fine
Echo simply prints a string to the pipe stdout (default)
per: https://superuser.com/a/699500/527937
Pipes can't overflow. A pipe is just a buffer (a certain amount of
memory, most likely 64KB on a current system) between a producer and a
consumer. If the producer produces faster than the consumer consumes,
the producer is blocked (that means, the program will sleep) until the
consumer makes room in the buffer again by reading from it.
As a side note, if you have a large ammount of data in 1x line ... cat can hang and/or consume an enormous amount of system memory.
A DoS was the most likely too. I recall that I once displayed a binary file on my terminal, and when it finally finished, I got lots of command not found errors, which left me wondering if there was a way to abuse it.
– MechMK1
9 hours ago
these are most likly errors fromechoand not bash, eg it encountered a backslash command that is not recognized as an option
– CaffeineAddiction
9 hours ago
I can't seem to find a way to exploit this either. Too bad, that would have been cool to exploit.
– MechMK1
9 hours ago
thecatportion could most likly be exploited ... egecho '"ls' > attackerControlledFile.txt
– CaffeineAddiction
9 hours ago
Just outputs"lsfor me.
– MechMK1
8 hours ago
|
show 1 more comment
No, echo used in the example above is fine
Echo simply prints a string to the pipe stdout (default)
per: https://superuser.com/a/699500/527937
Pipes can't overflow. A pipe is just a buffer (a certain amount of
memory, most likely 64KB on a current system) between a producer and a
consumer. If the producer produces faster than the consumer consumes,
the producer is blocked (that means, the program will sleep) until the
consumer makes room in the buffer again by reading from it.
As a side note, if you have a large ammount of data in 1x line ... cat can hang and/or consume an enormous amount of system memory.
A DoS was the most likely too. I recall that I once displayed a binary file on my terminal, and when it finally finished, I got lots of command not found errors, which left me wondering if there was a way to abuse it.
– MechMK1
9 hours ago
these are most likly errors fromechoand not bash, eg it encountered a backslash command that is not recognized as an option
– CaffeineAddiction
9 hours ago
I can't seem to find a way to exploit this either. Too bad, that would have been cool to exploit.
– MechMK1
9 hours ago
thecatportion could most likly be exploited ... egecho '"ls' > attackerControlledFile.txt
– CaffeineAddiction
9 hours ago
Just outputs"lsfor me.
– MechMK1
8 hours ago
|
show 1 more comment
No, echo used in the example above is fine
Echo simply prints a string to the pipe stdout (default)
per: https://superuser.com/a/699500/527937
Pipes can't overflow. A pipe is just a buffer (a certain amount of
memory, most likely 64KB on a current system) between a producer and a
consumer. If the producer produces faster than the consumer consumes,
the producer is blocked (that means, the program will sleep) until the
consumer makes room in the buffer again by reading from it.
As a side note, if you have a large ammount of data in 1x line ... cat can hang and/or consume an enormous amount of system memory.
No, echo used in the example above is fine
Echo simply prints a string to the pipe stdout (default)
per: https://superuser.com/a/699500/527937
Pipes can't overflow. A pipe is just a buffer (a certain amount of
memory, most likely 64KB on a current system) between a producer and a
consumer. If the producer produces faster than the consumer consumes,
the producer is blocked (that means, the program will sleep) until the
consumer makes room in the buffer again by reading from it.
As a side note, if you have a large ammount of data in 1x line ... cat can hang and/or consume an enormous amount of system memory.
answered 9 hours ago
CaffeineAddictionCaffeineAddiction
5,82121235
5,82121235
A DoS was the most likely too. I recall that I once displayed a binary file on my terminal, and when it finally finished, I got lots of command not found errors, which left me wondering if there was a way to abuse it.
– MechMK1
9 hours ago
these are most likly errors fromechoand not bash, eg it encountered a backslash command that is not recognized as an option
– CaffeineAddiction
9 hours ago
I can't seem to find a way to exploit this either. Too bad, that would have been cool to exploit.
– MechMK1
9 hours ago
thecatportion could most likly be exploited ... egecho '"ls' > attackerControlledFile.txt
– CaffeineAddiction
9 hours ago
Just outputs"lsfor me.
– MechMK1
8 hours ago
|
show 1 more comment
A DoS was the most likely too. I recall that I once displayed a binary file on my terminal, and when it finally finished, I got lots of command not found errors, which left me wondering if there was a way to abuse it.
– MechMK1
9 hours ago
these are most likly errors fromechoand not bash, eg it encountered a backslash command that is not recognized as an option
– CaffeineAddiction
9 hours ago
I can't seem to find a way to exploit this either. Too bad, that would have been cool to exploit.
– MechMK1
9 hours ago
thecatportion could most likly be exploited ... egecho '"ls' > attackerControlledFile.txt
– CaffeineAddiction
9 hours ago
Just outputs"lsfor me.
– MechMK1
8 hours ago
A DoS was the most likely too. I recall that I once displayed a binary file on my terminal, and when it finally finished, I got lots of command not found errors, which left me wondering if there was a way to abuse it.
– MechMK1
9 hours ago
A DoS was the most likely too. I recall that I once displayed a binary file on my terminal, and when it finally finished, I got lots of command not found errors, which left me wondering if there was a way to abuse it.
– MechMK1
9 hours ago
these are most likly errors from
echo and not bash, eg it encountered a backslash command that is not recognized as an option– CaffeineAddiction
9 hours ago
these are most likly errors from
echo and not bash, eg it encountered a backslash command that is not recognized as an option– CaffeineAddiction
9 hours ago
I can't seem to find a way to exploit this either. Too bad, that would have been cool to exploit.
– MechMK1
9 hours ago
I can't seem to find a way to exploit this either. Too bad, that would have been cool to exploit.
– MechMK1
9 hours ago
the
cat portion could most likly be exploited ... eg echo '"ls' > attackerControlledFile.txt– CaffeineAddiction
9 hours ago
the
cat portion could most likly be exploited ... eg echo '"ls' > attackerControlledFile.txt– CaffeineAddiction
9 hours ago
Just outputs
"ls for me.– MechMK1
8 hours ago
Just outputs
"ls for me.– MechMK1
8 hours ago
|
show 1 more comment
Does
echo "$(cat /etc/shadow)"
or
echo "$(mv test.txt test2.txt)"
Satisfy your requirement?
2
An attacker can modify the contents in the text file. I thought about command expansion, but as far as I know, command expansion occurs before cat even reads the file. Hence this approach does not work. I edited my question to clarify this.
– MechMK1
8 hours ago
@MechMK1 I see. I'll explore some more then.
– DarkMatter
8 hours ago
Sorry if I did not specify my requirements enough at first. I hope things are clear now. Sorry for any wasted effort
– MechMK1
8 hours ago
add a comment |
Does
echo "$(cat /etc/shadow)"
or
echo "$(mv test.txt test2.txt)"
Satisfy your requirement?
2
An attacker can modify the contents in the text file. I thought about command expansion, but as far as I know, command expansion occurs before cat even reads the file. Hence this approach does not work. I edited my question to clarify this.
– MechMK1
8 hours ago
@MechMK1 I see. I'll explore some more then.
– DarkMatter
8 hours ago
Sorry if I did not specify my requirements enough at first. I hope things are clear now. Sorry for any wasted effort
– MechMK1
8 hours ago
add a comment |
Does
echo "$(cat /etc/shadow)"
or
echo "$(mv test.txt test2.txt)"
Satisfy your requirement?
Does
echo "$(cat /etc/shadow)"
or
echo "$(mv test.txt test2.txt)"
Satisfy your requirement?
answered 8 hours ago
DarkMatterDarkMatter
2,4211121
2,4211121
2
An attacker can modify the contents in the text file. I thought about command expansion, but as far as I know, command expansion occurs before cat even reads the file. Hence this approach does not work. I edited my question to clarify this.
– MechMK1
8 hours ago
@MechMK1 I see. I'll explore some more then.
– DarkMatter
8 hours ago
Sorry if I did not specify my requirements enough at first. I hope things are clear now. Sorry for any wasted effort
– MechMK1
8 hours ago
add a comment |
2
An attacker can modify the contents in the text file. I thought about command expansion, but as far as I know, command expansion occurs before cat even reads the file. Hence this approach does not work. I edited my question to clarify this.
– MechMK1
8 hours ago
@MechMK1 I see. I'll explore some more then.
– DarkMatter
8 hours ago
Sorry if I did not specify my requirements enough at first. I hope things are clear now. Sorry for any wasted effort
– MechMK1
8 hours ago
2
2
An attacker can modify the contents in the text file. I thought about command expansion, but as far as I know, command expansion occurs before cat even reads the file. Hence this approach does not work. I edited my question to clarify this.
– MechMK1
8 hours ago
An attacker can modify the contents in the text file. I thought about command expansion, but as far as I know, command expansion occurs before cat even reads the file. Hence this approach does not work. I edited my question to clarify this.
– MechMK1
8 hours ago
@MechMK1 I see. I'll explore some more then.
– DarkMatter
8 hours ago
@MechMK1 I see. I'll explore some more then.
– DarkMatter
8 hours ago
Sorry if I did not specify my requirements enough at first. I hope things are clear now. Sorry for any wasted effort
– MechMK1
8 hours ago
Sorry if I did not specify my requirements enough at first. I hope things are clear now. Sorry for any wasted effort
– MechMK1
8 hours ago
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%2f211419%2fis-using-echo-to-display-attacker-controlled-data-on-the-terminal-dangerous%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
what if it's a million bells? while not dangerous, it's certainly annoying...
– dandavis
3 hours ago