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

Kernel Module Tampering

This note documents detection patterns related to Kernel Module Tampering on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
Shell historyinsmodManual kernel module insertionCriticalStrong privilege-level activity.
Shell historymodprobeModule load requestCriticalCommon legitimate tool, context critical.
Shell historyrmmodModule removalCriticalCan indicate cleanup or stealth tampering.
Shell historylsmodModule inspection before/after tamperingHighOften precedes malicious load.
Shell historydepmodDependency rebuildHighPersistence prep after module drop.
Shell historymodinfoModule inspectionMediumContext dependent.
/lib/modules/new .ko fileKernel object droppedCriticalPrimary module artifact.
/etc/modulesadded module nameBoot persistenceCriticalPersistent module loading.
/etc/modules-load.d/custom load filePersistent module loadCriticalModern persistence path.
File timestampsrecent .ko creationTimeline anchorCriticalCorrelates with privilege window.
dmesgmodule load messagesRuntime kernel evidenceCriticalStrong truth source.
journalctlkernel module eventsRuntime clueHighOften preserved.
auditdwrite to module pathsProcess attributionCriticalBest attribution if enabled.
Hidden .ko namecamouflage moduleCriticalOften mimics legit names.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Module load after sudo/root shellPrivilege exploitationCriticalStrong hostile sequence.
New module not matching installed kernel packageForeign moduleCriticalVery strong anomaly.
Module loaded from temp pathHighly suspiciousCriticalStrong malicious signal.
Module removed after short runtimeCleanup attemptCriticalPossible stealth rootkit behavior.
Module plus hidden fileConcealed persistenceCriticalStrong operator discipline.
/etc/modules modified recentlyBoot persistenceCriticalHigh-value persistence clue.
Module name mimics network driverCamouflageHighCommon stealth pattern.
Kernel logs gap around loadPossible anti-forensicsHighContext matters.
Root-owned new .ko outside package baselineCriticalStrong compromise indicator.
Module linked to outbound callbackRootkit-level C2CriticalHighest severity.

Common Tools

ToolUsage
insmodDirect kernel object insertion.
modprobeDependency-aware module load.
rmmodRemove loaded module.
lsmodInspect active modules.
depmodRebuild module dependencies.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
Module tree/lib/modules/CriticalPrimary module storage.
Boot modules/etc/modulesCriticalPersistent load path.
Modules-load config/etc/modules-load.d/CriticalPersistent load path.
Kernel logsdmesgCriticalLoad evidence.
Journaldjournalctl -kCriticalKernel timeline.
Shell history.bash_history, .zsh_historyCriticalOperator commands.
Audit logs/var/log/audit/audit.logCriticalFile write attribution.

MITRE ATT&CK References

  • T1547 Boot or Logon Autostart Execution
  • T1547.006 Kernel Modules and Extensions
  • T1014 Rootkit

Decision Tree

  1. Was module inserted or removed?

    • Search shell history and kernel logs.
  2. Is .ko file legitimate?

    • Compare against package baseline.
  3. Is persistence configured?

    • Check /etc/modules and modules-load configs.
  4. Did module run recently?

    • dmesg, journal kernel logs.
  5. Is module linked to hidden payload?

    • File names, timestamps, related binaries.
  6. Pivot

    • Module → hash / strings.
    • Timestamp → privilege timeline.
    • User → sudo/root path.
  7. Confirm tampering

    • New module + suspicious load path + intrusion context = strong kernel tampering finding.

Example Detection Templates

Grep

grep -R "insmod\|modprobe\|rmmod\|depmod" /home/*/.bash_history /root/.bash_history 2>/dev/null
find /lib/modules -name "*.ko" -printf '%TY-%Tm-%Td %TT %p\n' 2>/dev/null | sort
grep -R "." /etc/modules /etc/modules-load.d 2>/dev/null

Journalctl

journalctl -k | grep -E "module|insmod|modprobe"

File Inspection

dmesg | grep -i module
lsmod

Sigma

title: Linux Kernel Module Tampering
id: linux-kernel-module-tampering
status: experimental
description: Detects suspicious kernel module insertion or persistence activity
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'insmod'
      - 'modprobe'
      - 'rmmod'
      - '.ko'
  condition: selection_keywords
fields:
  - message
  - hostname
falsepositives:
  - Legitimate driver installation
level: high
tags:
  - attack.persistence
  - attack.t1547.006

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Module signingEnforce signed modulesCriticalBlocks arbitrary module insertion.
AuditdTrack module load commandsCriticalStrong attribution.
Baseline modulesInventory expected .ko filesHighUnknown modules stand out.
Restrict rootLimit module load privilegesHighCore prevention.
Kernel log retentionPreserve dmesg / journaldHighNeeded for timeline proof.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Was insmod/modprobe used?grep historyImmediate module check.
Any new .ko files?find modulesArtifact discovery.
Is module persistent?inspect /etc/modulesBoot persistence clue.
Did kernel log load event?dmesg / journalctl -kRuntime proof.
Is module name suspicious?compare baselineAnomaly scoring.
Is module linked to other persistence?inspect nearby artifactsFull chain view.

High Value Grep Strings

PatternWhy It Matters
insmodDirect module insertion.
modprobeStandard module load.
rmmodModule removal.
.koKernel object file.
/etc/modulesBoot persistence path.
depmodDependency rebuild clue.

Analyst Notes

ScenarioInterpretation
.ko loaded from temp pathVery strong malicious signal.
New module plus hidden configRootkit-style persistence possible.
Module removed quicklyCleanup or stealth attempt.
Module name mimics legit driverCamouflage likely.
/etc/modules modified after root shellPersistent kernel tampering.
Outbound callback near module loadHighest severity investigation.