5.11 Ensure Access to .git Files Is Restricted

Information

Restrict access to any files beginning with .git using the FilesMatch directive.

Rationale:

More and more websites track their changes in a Git repository we see a lot of attackers search for .git directories. Access to .git directories should be restricted. These files should be placed in the document root, but, in the event they are, the FilesMatch directive can be used to prevent them from being viewed by web clients.

Impact:

.git files are not accessible.

Solution

Perform the following to implement the recommended state:
Add or modify the following lines in the Apache configuration file at the server configuration level.

<DirectoryMatch '/.git'>
Require all denied
</DirectoryMatch>

Default Value:

This is not set by default

See Also

https://workbench.cisecurity.org/files/4548

Item Details

Category: CONFIGURATION MANAGEMENT, SYSTEM AND COMMUNICATIONS PROTECTION

References: 800-53|CM-10, 800-53|CM-11, 800-53|SC-18, CSCv7|18.2

Plugin: Unix

Control ID: 8a50b7ea5071c2f7dc661f06fb442885b2cafd9960af5d02bb84cdb0e5d3dfe3