Skip to content

Commit 21e7fd7

Browse files
scudettesnyk-bot
andcommitted
Implemented static analysis for client side permissions (#4246)
Client side artifacts run on the endpoint without ACL enforcement. This is usually what we want but sometimes the extra permissions can give the user extra permissions on the end point. The artifact writer can specify required permissions which will be enforced by the server prior to collecting the artifact. However, sometimes the artifact can use plugins with high priviledge safely - in that case we do not want to restrict the users that may collect it. For example say the artifact collects autoruns by shelling to the autoruns.exe tool. Even though it is using the execve() plugin this call is safe because the args are fixed and can not be influenced by the user. However if the artifact passed user input into the execve() plugin, the user requires the EXECVE permission. Previously, the artifact could declare EXECVE as a required permission, for artifact uses where user input was directly allowed in execve() calls. This enforces additional checks on the launching user to ensure they have the EXECVE permission. This PR modifies the artifact verifier to track plugin permissions used in the artifact. This allows us to see if the artifact inadvertantly gives the user permissions they do not have. This PR introduces another field to the artifact definition called `implied_permissions` where the artifact writer can declare permissions which the artifact will give but the user does not require those. This helps the verifier identify additional permissions that are accidentally given to users on the client. This PR adds a test to ensure built in artifacts have all necessary permissions declared either in `required_permissions` or `implied_permissions` --------- Co-authored-by: snyk-bot <[email protected]>
1 parent c8134f8 commit 21e7fd7

File tree

46 files changed

+646
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+646
-360
lines changed

accessors/pst/cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build !linux && !386
2-
// +build !linux,!386
1+
//go:build !386
2+
// +build !386
33

44
package pst
55

accessors/pst/pst_accessor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build !linux && !386
2-
// +build !linux,!386
1+
//go:build !386
2+
// +build !386
33

44
package pst
55

artifacts/definitions/Admin/Client/UpdateClientConfig.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ parameters:
2525
default: Y
2626
description: Should the client rekey its client ID.
2727

28+
required_permissions:
29+
- EXECVE
30+
- FILESYSTEM_WRITE
31+
2832
sources:
2933
- query: |
3034

artifacts/definitions/Admin/Client/Upgrade/Debian.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ parameters:
2424
description: |
2525
The name of the service to restart after the upgrade.
2626
27+
implied_permissions:
28+
- EXECVE
29+
- FILESYSTEM_WRITE
30+
2731
sources:
2832
- precondition:
2933
SELECT OS From info() where OS =~ 'linux'

artifacts/definitions/Admin/Client/Upgrade/RedHat.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ parameters:
2424
description: |
2525
The name of the service to restart after the upgrade.
2626
27+
implied_permissions:
28+
- EXECVE
29+
2730
sources:
2831
- precondition:
2932
SELECT OS From info() where OS =~ 'linux'

artifacts/definitions/Admin/Client/Upgrade/Windows.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ parameters:
2222
overwhelm the server so we stagger the download over this many
2323
seconds.
2424
25+
implied_permissions:
26+
- EXECVE
27+
- FILESYSTEM_WRITE
28+
2529
sources:
2630
- precondition:
2731
SELECT OS From info() where OS = 'windows'

artifacts/definitions/Generic/Client/CleanupTemp.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ parameters:
1313
- name: ReadllyDoIt
1414
type: bool
1515

16+
required_permissions:
17+
- FILESYSTEM_WRITE
1618

1719
sources:
1820
- query: |

artifacts/definitions/Generic/Client/DiskSpace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ description: |
66
1. On Linux and MacOS we call `df -h`.
77
2. On Windows we use WMI
88
9+
implied_permissions:
10+
- EXECVE
11+
912
sources:
1013
- query: |
1114
LET NonWindows = SELECT * FROM foreach(row={

artifacts/definitions/Generic/Client/VQL.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: |
33
Run arbitrary VQL on the endpoint.
44
55
required_permissions:
6-
- EXECVE
6+
- IMPERSONATION
77

88
parameters:
99
- name: Command

artifacts/definitions/Generic/Forensic/LocalHashes/Init.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ parameters:
88
description: Name of the local hash database
99
default: hashdb.sqlite
1010

11+
implied_permissions:
12+
- FILESYSTEM_WRITE
13+
1114
sources:
1215
- query: |
1316
LET SQL = "

artifacts/definitions/Generic/Utils/FetchBinary.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ parameters:
4242
- name: Version
4343
description: The version of the tool to fetch
4444

45+
implied_permissions:
46+
- SERVER_ADMIN
47+
- FILESYSTEM_WRITE
48+
4549
sources:
4650
- query: |
4751
-- The following VQL is particularly ancient because it is

artifacts/definitions/Linux/Network/PacketCapture.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,29 @@ description: |
66
The `Duration` parameter is used to define how long (in seconds) the capture should be. Specific interfaces can be defined using the `Interface` parameter, otherwise the artifact defaults to an interface assignment of `any`.
77
88
A `BPF` (Berkeley Packet Filter) expression can also be supplied to filter the captured traffic as desired.
9-
9+
1010
Read more about BPF expressions here: https://biot.com/capstats/bpf.html
1111
1212
required_permissions:
1313
- EXECVE
1414

15+
implied_permissions:
16+
- FILESYSTEM_WRITE
17+
1518
parameters:
1619
- name: Duration
1720
type: integer
1821
description: Duration (in seconds) of PCAP to be recorded.
1922
default: 10
20-
23+
2124
- name: Interface
2225
type: string
2326
default: any
2427

2528
- name: BPF
2629
type: string
2730
default:
28-
31+
2932
precondition:
3033
SELECT * FROM info() where OS = 'linux'
3134

artifacts/definitions/Linux/RHEL/Packages.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Linux.RHEL.Packages
22
description: |
33
Parse packages installed from dnf or yum
4+
5+
implied_permissions:
6+
- EXECVE
7+
48
sources:
59
- precondition: |
610
SELECT OS From info() where OS = 'linux'

artifacts/definitions/Linux/SuSE/Packages.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ author: Hilko Bengen <[email protected]>
33
description: |
44
Parse list of installed packages from zypper output
55
6+
implied_permissions:
7+
- EXECVE
8+
69
sources:
710
- precondition: |
811
SELECT OS From info() WHERE OS = 'linux'
@@ -12,11 +15,11 @@ sources:
1215
FROM execve(
1316
length=1000000,
1417
argv=["zypper", "--xmlout", "search", "--installed-only", "--details", "--type=package"])
15-
18+
1619
LET xml = parse_xml(
1720
file=str(str=zypper_output.Stdout),
1821
accessor="data")
19-
22+
2023
SELECT *
2124
FROM foreach(
2225
row=xml.stream.`search-result`.`solvable-list`.solvable,

artifacts/definitions/Linux/Sys/Services.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
name: Linux.Sys.Services
2-
description: Parse services from systemctl
2+
description: Parse services from systemctl
3+
4+
implied_permissions:
5+
- EXECVE
36

47
sources:
58
- precondition: |
69
SELECT OS From info() where OS = 'linux'
710
queries:
811
- |
912
LET services = SELECT Stdout FROM execve(argv=['systemctl', 'list-units', '--type=service'])
10-
13+
1114
LET all_services = SELECT grok(grok="%{NOTSPACE:Unit}%{SPACE}%{NOTSPACE:Load}%{SPACE}%{NOTSPACE:Active}%{SPACE}%{NOTSPACE:Sub}%{SPACE}%{GREEDYDATA:Description}", data=Line) AS Parsed
1215
FROM parse_lines(accessor="data", filename=services.Stdout)
13-
16+
1417
SELECT * FROM foreach(row=all_services, column="Parsed") WHERE Unit =~ ".service"
15-
16-

artifacts/definitions/Linux/Users/RootUsers.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ author: George-Andrei Iosif (@iosifache)
77

88
type: CLIENT
99

10+
implied_permissions:
11+
- EXECVE
12+
1013
sources:
1114
- precondition: |
1215
SELECT OS

artifacts/definitions/Linux/Utils/InstallDeb.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type: CLIENT
3131

3232
required_permissions:
3333
- EXECVE
34+
- FILESYSTEM_WRITE
3435

3536
reference:
3637
- https://manpages.debian.org/bookworm/debconf-doc/debconf-devel.7.en.html#Type

artifacts/definitions/MacOS/Network/PacketCapture.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,29 @@ description: |
66
The `Duration` parameter is used to define how long (in seconds) the capture should be. Specific interfaces can be defined using the `Interface` parameter, otherwise the artifact defaults to an interface assignment of `any`.
77
88
A `BPF` (Berkeley Packet Filter) expression can also be supplied to filter the captured traffic as desired.
9-
9+
1010
Read more about BPF expressions here: https://biot.com/capstats/bpf.html
1111
1212
required_permissions:
1313
- EXECVE
1414

15+
implied_permissions:
16+
- FILESYSTEM_WRITE
17+
1518
parameters:
1619
- name: Duration
1720
type: integer
1821
description: Duration (in seconds) of PCAP to be recorded.
1922
default: 10
20-
23+
2124
- name: Interface
2225
type: string
2326
default: any
2427

2528
- name: BPF
2629
type: string
2730
default:
28-
31+
2932
precondition:
3033
SELECT * FROM info() where OS = 'darwin'
3134

artifacts/definitions/MacOS/System/Packages.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
name: MacOS.System.Packages
22
description: |
33
Parse packages installed on Macs
4+
45
parameters:
56
- name: Length
67
description: Size (in bytes) of output that will be returned
78
type: int
89
default: "100000000"
10+
11+
implied_permissions:
12+
- EXECVE
13+
914
sources:
1015
- precondition: |
1116
SELECT OS From info() where OS = 'darwin'
1217
query: |
13-
LET packages = SELECT parse_json(data=Stdout) AS Json
18+
LET packages = SELECT parse_json(data=Stdout) AS Json
1419
FROM execve(argv=[
1520
"system_profiler", "-json", "SPApplicationsDataType"
1621
], length=Length)
1722
1823
SELECT _name AS Name,
19-
get(field="version") AS Version,
20-
path AS Path,
21-
lastModified AS LastModified,
24+
get(field="version") AS Version,
25+
path AS Path,
26+
lastModified AS LastModified,
2227
obtained_from AS ObtainedFrom,
2328
get(field="signed_by") AS SignedBy,
2429
arch_kind AS _Architecture

artifacts/definitions/Windows/ActiveDirectory/BloodHound.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ reference:
2323
required_permissions:
2424
- EXECVE
2525

26+
implied_permissions:
27+
- FILESYSTEM_WRITE
28+
2629
tools:
2730
- name: SharpHound
2831
url: https://github.com/BloodHoundAD/BloodHound/raw/master/Collectors/SharpHound.exe

artifacts/definitions/Windows/Applications/NirsoftBrowserViewer.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ parameters:
3838
default: LOCAL
3939
description: Default timezone for parsing timestamps
4040

41+
implied_permissions:
42+
- EXECVE
43+
- FILESYSTEM_WRITE
44+
4145
sources:
4246
- precondition:
4347
SELECT OS From info() where OS = 'windows'

artifacts/definitions/Windows/Applications/SBECmd.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ tools:
3434

3535
precondition: SELECT OS From info() where OS = 'windows'
3636

37+
implied_permissions:
38+
- EXECVE
39+
- FILESYSTEM_WRITE
40+
3741
parameters:
3842
- name: userRegex
3943
default: .

artifacts/definitions/Windows/Forensics/BulkExtractor.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ author: Matt Green - @mgreen27
4545
required_permissions:
4646
- EXECVE
4747

48+
implied_permissions:
49+
- FILESYSTEM_WRITE
50+
4851
tools:
4952
- name: Bulk_Extractor_Binary
5053
url: https://github.com/Velocidex/Tools/raw/main/BulkExtractor/bulk_extractor.exe

artifacts/definitions/Windows/Memory/Acquisition.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ description: |
2020
go-winpmem.exe expand image.compressed image.raw
2121
```
2222
23+
implied_permissions:
24+
- FILESYSTEM_WRITE
25+
2326
precondition: |
2427
SELECT OS FROM info()
2528
WHERE OS = 'windows'

artifacts/definitions/Windows/Network/PacketCapture.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ tools:
1515
- name: etl2pcapng
1616
url: https://github.com/microsoft/etl2pcapng/releases/download/v1.4.0/etl2pcapng.zip
1717

18+
implied_permissions:
19+
- FILESYSTEM_WRITE
20+
- EXECVE
21+
1822
parameters:
1923
- name: StartTrace
2024
type: bool

artifacts/definitions/Windows/Remediation/Sinkhole.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ author: Matt Green - @mgreen27
2020
required_permissions:
2121
- EXECVE
2222

23+
implied_permissions:
24+
- FILESYSTEM_WRITE
25+
2326
type: CLIENT
2427

2528
parameters:

artifacts/definitions/Windows/Sys/Interfaces.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ description: |
33
Report information about the systems interfaces. This artifact
44
simply parses the output from ipconfig /all.
55
6+
implied_permissions:
7+
- EXECVE
8+
69
sources:
710
- precondition:
811
SELECT OS from info() where OS = "windows"

artifacts/definitions/Windows/Sysinternals/Autoruns.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ tools:
1515

1616
precondition: SELECT OS From info() where OS = 'windows'
1717

18+
implied_permissions:
19+
- EXECVE
20+
1821
parameters:
1922
- name: All
2023
type: bool

0 commit comments

Comments
 (0)