Führe statische Analyse (SAST) auf der Codebasis aus und suche im Datenfluss nach dem unsicheren Muster.
Improper Address Validation in IOCTL with METHOD_NEITHER I/O Control Code
This vulnerability occurs when a Windows driver defines an IOCTL using METHOD_NEITHER but fails to properly check the user-supplied memory addresses before using them.
What is CWE-781?
Real-world CVEs caused by CWE-781
-
Driver for file-sharing and messaging protocol allows attackers to execute arbitrary code.
-
Anti-virus product does not validate addresses, allowing attackers to gain SYSTEM privileges.
-
DVD software allows attackers to cause a crash.
-
Personal firewall allows attackers to gain SYSTEM privileges.
-
chain: device driver for packet-capturing software allows access to an unintended IOCTL with resultant array index error.
Angreiferpfad Schritt für Schritt
- 1
Identifiziere einen Codepfad, der nicht vertrauenswürdige Eingaben ohne Validierung verarbeitet.
- 2
Erzeuge eine Payload, die das unsichere Verhalten auslöst — Injection, Traversal, Overflow oder Logik-Missbrauch.
- 3
Liefere die Payload über einen normalen Request aus und beobachte die Reaktion der Anwendung.
- 4
Iteriere, bis die Antwort Daten preisgibt, Angreifer-Code ausführt oder Berechtigungen eskaliert.
Vulnerable pseudo
MITRE hat kein Codebeispiel für diese CWE veröffentlicht. Das untenstehende Muster ist illustrativ — kanonische Referenzen findest du unter Ressourcen.
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
// Untrusted input flows directly into the sensitive sink.
return executeUnsafe(input);
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-781
- Implementation If METHOD_NEITHER is required for the IOCTL, then ensure that all user-space addresses are properly validated before they are first accessed. The ProbeForRead and ProbeForWrite routines are available for this task. Also properly protect and manage the user-supplied buffers, since the I/O Manager does not do this when METHOD_NEITHER is being used. See References.
- Architecture and Design If possible, avoid using METHOD_NEITHER in the IOCTL and select methods that effectively control the buffer size, such as METHOD_BUFFERED, METHOD_IN_DIRECT, or METHOD_OUT_DIRECT.
- Architecture and Design / Implementation If the IOCTL is part of a driver that is only intended to be accessed by trusted users, then use proper access control for the associated device or device namespace. See References.
How to detect CWE-781
Führe dynamische Application-Security-Tests gegen den Live-Endpoint aus.
Beobachte Runtime-Logs auf ungewöhnliche Exception-Traces, fehlerhafte Eingaben oder Versuche, Autorisierung zu umgehen.
Code Review: Markiere jeden neuen Code, der Eingaben von dieser Oberfläche ohne validierte Framework-Helper verarbeitet.
Plexicus erkennt CWE-781 automatisch und öffnet in unter 60 Sekunden einen Fix-PR.
Codex Remedium scannt jeden Commit, identifiziert genau diese Schwachstelle und liefert einen reviewer-ready Pull Request mit dem Patch. Keine Tickets. Keine Hand-offs.
Frequently asked questions
Was ist CWE-781?
This vulnerability occurs when a Windows driver defines an IOCTL using METHOD_NEITHER but fails to properly check the user-supplied memory addresses before using them.
Wie gravierend ist CWE-781?
MITRE hat für diese Schwachstelle keine Exploit-Wahrscheinlichkeit veröffentlicht. Behandle sie als mittlere Auswirkung, bis dein Threat Model anderes belegt.
Welche Sprachen oder Plattformen sind von CWE-781 betroffen?
MITRE lists the following affected platforms: C, C++, Windows NT.
Wie kann ich CWE-781 verhindern?
If METHOD_NEITHER is required for the IOCTL, then ensure that all user-space addresses are properly validated before they are first accessed. The ProbeForRead and ProbeForWrite routines are available for this task. Also properly protect and manage the user-supplied buffers, since the I/O Manager does not do this when METHOD_NEITHER is being used. See References. If possible, avoid using METHOD_NEITHER in the IOCTL and select methods that effectively control the buffer size, such as…
Wie erkennt und behebt Plexicus CWE-781?
Die SAST-Engine von Plexicus erkennt die Datenfluss-Signatur von CWE-781 bei jedem Commit. Bei einem Treffer öffnet unser Codex-Remedium-Agent einen Fix-PR mit korrigiertem Code, Tests und einer einzeiligen Zusammenfassung für den Reviewer.
Wo erfahre ich mehr über CWE-781?
MITRE veröffentlicht die kanonische Definition unter https://cwe.mitre.org/data/definitions/781.html. Für ergänzende Hinweise kannst du auch die OWASP- und NIST-Dokumentation heranziehen.
Weaknesses related to CWE-781
Improper Validation of Specified Index, Position, or Offset in Input
This vulnerability occurs when software accepts user input to determine a location—like an array index, file position, or memory…
Improper Validation of Array Index
This vulnerability occurs when software uses unverified, external input to calculate or access an array index, without properly checking…
Untrusted Pointer Dereference
This vulnerability occurs when software takes a value from an untrusted source, treats it as a memory address (a pointer), and then…
Further reading
- MITRE — offizielle CWE-781 https://cwe.mitre.org/data/definitions/781.html
- Exploiting Common Flaws in Drivers http://reversemode.com/index.php?option=com_content&task=view&id=38&Itemid=1
- Remote and Local Exploitation of Network Drivers https://www.blackhat.com/presentations/bh-usa-07/Bulygin/Presentation/bh-usa-07-bulygin.pdf
- Windows driver vulnerabilities: the METHOD_NEITHER odyssey http://www.net-security.org/dl/insecure/INSECURE-Mag-18.pdf
- Buffer Descriptions for I/O Control Codes https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/buffer-descriptions-for-i-o-control-codes
- Using Neither Buffered Nor Direct I/O https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/using-neither-buffered-nor-direct-i-o
- Securing Device Objects https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/controlling-device-access
Schluss mit dem Bezahlen pro Entwickler.
Schließ den Kreislauf.
Plexicus ist die KI-native ASPM, die scannt, filtert, fixt, pentestet und erklärt — autonom. Unbegrenzte Entwickler, unbegrenzte Repos, Fair-Use-KI-Aktionen. Echter kostenloser Tarif, €269/mo jährlich, wenn du bereit bist.