File size: 2,833 Bytes
fc93158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{
  "cases": [
    {
      "name": "direct argv infers display command",
      "command": ["echo", "hi there"],
      "expected": {
        "valid": true,
        "displayCommand": "echo \"hi there\""
      }
    },
    {
      "name": "direct argv rejects mismatched raw command",
      "command": ["uname", "-a"],
      "rawCommand": "echo hi",
      "expected": {
        "valid": false,
        "errorContains": "rawCommand does not match command"
      }
    },
    {
      "name": "shell wrapper accepts shell payload raw command at ingress",
      "command": ["/bin/sh", "-lc", "echo hi"],
      "rawCommand": "echo hi",
      "expected": {
        "valid": true,
        "displayCommand": "/bin/sh -lc \"echo hi\""
      }
    },
    {
      "name": "shell wrapper positional argv carrier requires full argv display binding",
      "command": ["/bin/sh", "-lc", "$0 \"$1\"", "/usr/bin/touch", "/tmp/marker"],
      "rawCommand": "$0 \"$1\"",
      "expected": {
        "valid": false,
        "errorContains": "rawCommand does not match command"
      }
    },
    {
      "name": "shell wrapper positional argv carrier accepts canonical full argv raw command",
      "command": ["/bin/sh", "-lc", "$0 \"$1\"", "/usr/bin/touch", "/tmp/marker"],
      "rawCommand": "/bin/sh -lc \"$0 \\\"$1\\\"\" /usr/bin/touch /tmp/marker",
      "expected": {
        "valid": true,
        "displayCommand": "/bin/sh -lc \"$0 \\\"$1\\\"\" /usr/bin/touch /tmp/marker"
      }
    },
    {
      "name": "env wrapper shell payload accepted at ingress when prelude has no env modifiers",
      "command": ["/usr/bin/env", "bash", "-lc", "echo hi"],
      "rawCommand": "echo hi",
      "expected": {
        "valid": true,
        "displayCommand": "/usr/bin/env bash -lc \"echo hi\""
      }
    },
    {
      "name": "env wrapper accepts canonical full argv raw command",
      "command": ["/usr/bin/env", "bash", "-lc", "echo hi"],
      "rawCommand": "/usr/bin/env bash -lc \"echo hi\"",
      "expected": {
        "valid": true,
        "displayCommand": "/usr/bin/env bash -lc \"echo hi\""
      }
    },
    {
      "name": "env assignment prelude requires full argv display binding",
      "command": ["/usr/bin/env", "BASH_ENV=/tmp/payload.sh", "bash", "-lc", "echo hi"],
      "rawCommand": "echo hi",
      "expected": {
        "valid": false,
        "errorContains": "rawCommand does not match command"
      }
    },
    {
      "name": "env assignment prelude accepts canonical full argv raw command",
      "command": ["/usr/bin/env", "BASH_ENV=/tmp/payload.sh", "bash", "-lc", "echo hi"],
      "rawCommand": "/usr/bin/env BASH_ENV=/tmp/payload.sh bash -lc \"echo hi\"",
      "expected": {
        "valid": true,
        "displayCommand": "/usr/bin/env BASH_ENV=/tmp/payload.sh bash -lc \"echo hi\""
      }
    }
  ]
}