Directive reference

ModSecurity configuration directives

A practical reference to engine, body inspection, limits, audit logging, uploads, remote rules, and rule-management directives.

Adapted ModSecurity documentationThis page has been reorganized, rewritten, and supplemented by Atomicorp from upstream ModSecurity reference material. Source, license, and attribution details.

Directives configure the engine around your rules: what ModSecurity inspects, how much data it buffers, where it logs, and how loaded rules are changed. Support and scope differ between ModSecurity 2.x and libmodsecurity 3, so verify a directive against your installed engine and connector.

Engine and rule loading

DirectivePurpose
SecRuleEngineSelects On, Off, or DetectionOnly processing.
SecRuleEvaluates variables with an operator and actions.
SecActionRuns actions without evaluating a variable/operator pair.
SecDefaultActionSupplies inherited phase, logging, and disruptive defaults.
SecMarkerCreates a named destination for skipAfter.
SecComponentSignatureAdds a component identifier to ModSecurity’s signature.
SecRemoteRulesLoads rules from an HTTPS endpoint using a key.
SecRemoteRulesFailActionChooses Abort or Warn if remote rules cannot load.

Request inspection and limits

DirectivePurpose
SecRequestBodyAccessEnables or disables request-body inspection.
SecRequestBodyLimitCaps the total buffered request body.
SecRequestBodyNoFilesLimitCaps non-file request-body data.
SecRequestBodyInMemoryLimitSets how much request data is retained in memory.
SecRequestBodyLimitActionChooses how an over-limit body is handled.
SecArgumentsLimitLimits the number of parsed request arguments.
SecArgumentSeparatorDefines the application argument separator.
SecCookieFormatSelects the expected cookie parsing format.
SecUnicodeMapFileSupplies Unicode mapping used by urlDecodeUni.

Limits are security and availability controls. Do not raise them globally to accommodate one upload route without considering memory, concurrency, and application-specific scoping.

Response inspection

DirectivePurpose
SecResponseBodyAccessEnables response-body buffering and inspection.
SecResponseBodyMimeTypeSelects response MIME types to inspect.
SecResponseBodyLimitCaps the response body retained for inspection.
SecResponseBodyLimitActionChooses what happens when a response exceeds the limit.

Response inspection supports data-loss and malicious-output controls but adds cost. Enable only the MIME types and sizes your policy needs.

Audit and debug logging

DirectivePurpose
SecAuditEngineSelects On, Off, or RelevantOnly audit logging.
SecAuditLogSets the serial audit-log file or concurrent index.
SecAuditLogTypeSelects serial or concurrent audit logging.
SecAuditLogStorageDirSets the transaction directory for concurrent logs.
SecAuditLogPartsSelects transaction sections to record.
SecAuditLogRelevantStatusDefines relevant response statuses.
SecAuditLogFormatSelects the supported audit format.
SecDebugLogSets the diagnostic log file.
SecDebugLogLevelControls diagnostic verbosity.

Debug logging can be extremely verbose. Raise the level temporarily for a focused investigation, then return it to an operational setting.

File handling and storage

DirectivePurpose
SecTmpDirSets a directory for temporary files.
SecDataDirSets persistent storage used by collections and other features.
SecUploadDirSets the intercepted-upload directory.
SecUploadKeepFilesControls whether uploaded files are retained.
SecUploadFileModeSets retained-upload permissions.
SecUploadFileLimitLimits the number of files processed in one request.

These directories must be writable by the web-server account and must not be web-accessible. Treat retained uploads as untrusted data.

Changing loaded rules

DirectivePurpose
SecRuleRemoveByIdRemoves rules by ID or ID range.
SecRuleRemoveByMsgRemoves rules matching message text.
SecRuleRemoveByTagRemoves rules matching a tag.
SecRuleUpdateActionByIdChanges actions on a loaded rule.
SecRuleUpdateTargetByIdAdds or removes inspected targets for a rule ID.
SecRuleUpdateTargetByTagChanges targets for rules selected by tag.

Prefer ID- and target-based changes over message matching. Keep exclusions in a separate local file so vendor updates do not overwrite them.

Source and version note

This operational summary is adapted from the ModSecurity reference material. Consult the exhaustive upstream 2.x directive reference and 3.x reference for syntax, defaults, scope, version introduction, and connector support. The upstream manuals are copyright Trustwave Holdings, Inc.; ModSecurity is licensed under Apache License 2.0.