Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / CONTAINERS

Container Escape

This note documents detection patterns related to Container Escape or Docker Abuse on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
Shell historydocker psContainer enumerationHighOften first attacker step after foothold.
Shell historydocker exec -itInteractive container accessCriticalStrong container pivot indicator.
Shell historydocker run -v /:/mntHost filesystem mountCriticalClassic host escape / abuse pattern.
Shell historydocker run --privilegedPrivileged container launchCriticalHigh-confidence abuse path.
Shell historydocker cpFile transfer into/out of containerHighUseful for payload staging.
Shell historydocker inspectContainer reconnaissanceHighOften precedes abuse.
Shell historydocker commitSnapshot modified containerMediumContext dependent.
Shell historynsenterNamespace escapeCriticalStrong host escape indicator.
Shell historychroot /mntHost pivot after mountCriticalStrong escape sequence.
/var/lib/docker/unexpected new artifactsContainer modificationHighPersistence / payload staging clue.
Docker daemon logsprivileged container startRuntime evidenceCriticalStrong operational proof.
journalctldocker service activityRuntime clueCriticalPrimary host-side source.
auditddocker / nsenter executionProcess attributionCriticalBest attribution if enabled.
Mounted host paths/:/mnt style mountsHost exposureCriticalHigh severity artifact.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Docker commands after sudo/rootHost abuse progressionCriticalCommon attacker path.
Privileged container after footholdEscape attemptCriticalStrong hostile sequence.
Host filesystem visible in containerNear-confirmed escape pathCriticalHigh severity.
Container launched from unusual imagePayload carrierHighStrong anomaly if unknown image.
Docker socket access by low-priv userPrivilege abuseCriticalOften equivalent to root.
nsenter after docker mountMature operator behaviorCriticalStrong escape indicator.
Container plus cron/service on hostHost persistence post-escapeCriticalFull compromise chain.
Hidden payload under /var/lib/dockerConcealed persistenceHighRequires deeper review.
Docker used for outbound pivotNetwork stagingHighMulti-host movement clue.
Docker history missing after useCleanup attemptHighAnti-forensic behavior.

Common Tools

ToolUsage
docker execAccess running container.
docker run --privilegedLaunch high-privilege container.
docker run -v /:/mntMount host filesystem.
docker cpTransfer files.
docker inspectContainer metadata reconnaissance.
nsenterNamespace pivot to host.
chrootPivot into mounted host FS.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
Shell history.bash_history, .zsh_historyCriticalPrimary command evidence.
Docker data/var/lib/docker/HighImage/container artifact source.
Docker socket/var/run/docker.sockCriticalPrivilege pivot target.
Docker daemon logsjournald / service logsCriticalRuntime truth.
Audit logs/var/log/audit/audit.logCriticalProcess attribution.
Mounted host tracesbind mount pathsCriticalEscape proof.

MITRE ATT&CK References

  • T1611 Escape to Host
  • T1610 Deploy Container
  • T1611 Container and Resource Discovery

Decision Tree

  1. Was docker used?

    • Search shell history and daemon logs.
  2. Was privileged mode used?

    • Identify --privileged, host mounts.
  3. Was host filesystem exposed?

    • Inspect mount arguments.
  4. Was namespace escape attempted?

    • Look for nsenter, chroot.
  5. Did host persistence follow?

    • Cron, services, keys, startup files.
  6. Pivot

    • Container → image / mounts.
    • User → docker group / sudo context.
    • Timeline → privilege sequence.
  7. Confirm abuse

    • Privileged docker + host mount + escape tooling = strong host compromise path.

Example Detection Templates

Grep

grep -R "docker exec\|docker run --privileged\|docker run -v /\|docker cp\|docker inspect\|nsenter\|chroot /mnt" /home/*/.bash_history /root/.bash_history 2>/dev/null
grep -R "docker " /home/*/.bash_history /root/.bash_history 2>/dev/null

Journalctl

journalctl | grep docker

File Inspection

ls -la /var/run/docker.sock
find /var/lib/docker -printf '%TY-%Tm-%Td %TT %p\n' 2>/dev/null | sort

Sigma

title: Linux Container Escape or Docker Abuse
id: linux-container-escape-docker-abuse
status: experimental
description: Detects suspicious docker activity associated with host escape or privileged abuse
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'docker run --privileged'
      - 'docker exec'
      - 'nsenter'
      - 'docker run -v /'
  condition: selection_keywords
fields:
  - message
  - hostname
falsepositives:
  - Legitimate container administration
level: high
tags:
  - attack.privilege_escalation
  - attack.t1611

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Docker socket controlRestrict socket accessCriticalDocker socket often equals root.
Privileged container policyBlock --privilegedCriticalRemoves key escape path.
Mount policyRestrict host bind mountsCriticalPrevents filesystem exposure.
AuditdTrack docker/nsenter commandsHighStrong attribution.
Docker group reviewMinimize membershipHighMajor privilege control.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Was docker used suspiciously?grep historyImmediate abuse check.
Any privileged launch?inspect commandsEscape clue.
Was host mounted?inspect -v usageHigh severity.
Was nsenter used?grep historyStrong host escape signal.
Did host persistence follow?inspect cron/servicesFull compromise chain.
Is docker socket exposed?inspect permissionsPrivilege context.

High Value Grep Strings

PatternWhy It Matters
docker execContainer pivot.
docker run --privilegedHigh-risk abuse.
docker run -v /:/mntHost mount escape.
docker cpPayload movement.
nsenterNamespace escape.
chroot /mntHost pivot after mount.

Analyst Notes

ScenarioInterpretation
Privileged container + host mountVery strong host compromise path.
Docker socket by low-priv userEffective root-level abuse.
nsenter after docker runMature escape behavior.
Hidden payload under docker pathsConcealed persistence possible.
Docker plus cron on hostEscape followed by persistence.
History cleared after docker abuseCleanup attempt likely.