Skip to content

[New Rule] PE through Writable Docker Socket #2958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 27, 2023

Conversation

Aegrah
Copy link
Contributor

@Aegrah Aegrah commented Jul 25, 2023

Summary

This rule monitors for the usage of Docker runtime sockets to escalate privileges on Linux systems. Docker sockets by default are only be writable by the root user and docker group. Attackers that have permissions to write to these sockets may be able to create and run a container that allows them to escalate privileges and gain further access onto the host file system.

Detection

0 hits last 365 days in red sector, nor in my docker test clusters. Added and not user.Ext.real.id : "0" and not group.Ext.real.id : "0" to minimize FPs.

process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and 
(
  (process.name == "docker" and process.args : "run" and process.args : "-it"  and 
   process.args : ("unix://*/docker.sock", "unix://*/dockershim.sock")) or 
  (process.name == "socat" and process.args : ("UNIX-CONNECT:*/docker.sock", "UNIX-CONNECT:*/dockershim.sock"))
) and not user.Ext.real.id : "0" and not group.Ext.real.id : "0"
image

Copy link
Contributor

@w0rk3r w0rk3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor

@eric-forte-elastic eric-forte-elastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great rule 🔥

There are some instances where users will need to use docker runtime sockets to route control of the docker interface in some more intricate development environments. However, these are few and far between and I have not seen one that also makes use of -it as one might use for privilege escalation. Great Work!

@Aegrah Aegrah merged commit bbb2470 into main Jul 27, 2023
@Aegrah Aegrah deleted the new-rule-pe-writabe-docker-socket branch July 27, 2023 08:01
protectionsmachine pushed a commit that referenced this pull request Jul 27, 2023
* [New Rule] PE through Writable Docker Socket

* simplified query

* Update privilege_escalation_writable_docker_socket.toml

* Update privilege_escalation_writable_docker_socket.toml

* Update rules/linux/privilege_escalation_writable_docker_socket.toml

Co-authored-by: Jonhnathan <[email protected]>

---------

Co-authored-by: Jonhnathan <[email protected]>

(cherry picked from commit bbb2470)
protectionsmachine pushed a commit that referenced this pull request Jul 27, 2023
* [New Rule] PE through Writable Docker Socket

* simplified query

* Update privilege_escalation_writable_docker_socket.toml

* Update privilege_escalation_writable_docker_socket.toml

* Update rules/linux/privilege_escalation_writable_docker_socket.toml

Co-authored-by: Jonhnathan <[email protected]>

---------

Co-authored-by: Jonhnathan <[email protected]>

(cherry picked from commit bbb2470)
protectionsmachine pushed a commit that referenced this pull request Jul 27, 2023
* [New Rule] PE through Writable Docker Socket

* simplified query

* Update privilege_escalation_writable_docker_socket.toml

* Update privilege_escalation_writable_docker_socket.toml

* Update rules/linux/privilege_escalation_writable_docker_socket.toml

Co-authored-by: Jonhnathan <[email protected]>

---------

Co-authored-by: Jonhnathan <[email protected]>

(cherry picked from commit bbb2470)
protectionsmachine pushed a commit that referenced this pull request Jul 27, 2023
* [New Rule] PE through Writable Docker Socket

* simplified query

* Update privilege_escalation_writable_docker_socket.toml

* Update privilege_escalation_writable_docker_socket.toml

* Update rules/linux/privilege_escalation_writable_docker_socket.toml

Co-authored-by: Jonhnathan <[email protected]>

---------

Co-authored-by: Jonhnathan <[email protected]>

(cherry picked from commit bbb2470)
protectionsmachine pushed a commit that referenced this pull request Jul 27, 2023
* [New Rule] PE through Writable Docker Socket

* simplified query

* Update privilege_escalation_writable_docker_socket.toml

* Update privilege_escalation_writable_docker_socket.toml

* Update rules/linux/privilege_escalation_writable_docker_socket.toml

Co-authored-by: Jonhnathan <[email protected]>

---------

Co-authored-by: Jonhnathan <[email protected]>

(cherry picked from commit bbb2470)
protectionsmachine pushed a commit that referenced this pull request Jul 27, 2023
* [New Rule] PE through Writable Docker Socket

* simplified query

* Update privilege_escalation_writable_docker_socket.toml

* Update privilege_escalation_writable_docker_socket.toml

* Update rules/linux/privilege_escalation_writable_docker_socket.toml

Co-authored-by: Jonhnathan <[email protected]>

---------

Co-authored-by: Jonhnathan <[email protected]>

(cherry picked from commit bbb2470)
protectionsmachine pushed a commit that referenced this pull request Jul 27, 2023
* [New Rule] PE through Writable Docker Socket

* simplified query

* Update privilege_escalation_writable_docker_socket.toml

* Update privilege_escalation_writable_docker_socket.toml

* Update rules/linux/privilege_escalation_writable_docker_socket.toml

Co-authored-by: Jonhnathan <[email protected]>

---------

Co-authored-by: Jonhnathan <[email protected]>

(cherry picked from commit bbb2470)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants