Web scanning is a critical phase of reconnaissance used by attackers to systematically probe for exposed private files and misconfigured directories. This article delves into the methods attackers use, analyzes detailed log data, and presents a robust set of best practices to mitigate file exposure risks.
Web scanning involves automated tools systematically testing various endpoints, paths, and filenames in search of misconfigured or inadvertently exposed files. Common targets include configuration files (.env
, config.json
), backup files (config.bak
, .env.old
), and test directories. These scans often generate distinctive patterns in server logs, as seen below:
78.153.140.151 - - [06/May/2025:19:42:38 +0000] GET /.env HTTP/1.1 404
78.153.140.151 - - [06/May/2025:19:42:39 +0000] GET /.env.backup HTTP/1.1 404
78.153.140.151 - - [06/May/2025:19:42:41 +0000] GET /config.json HTTP/1.1 404
78.153.140.151 - - [14/May/2025:13:41:33 +0000] GET /test/test HTTP/1.1 403
78.153.140.151 - - [14/May/2025:13:41:34 +0000] GET /STAGING/test HTTP/1.1 404
78.153.140.151 - - [10/May/2025:23:43:45 +0000] GET /ADMIN/test HTTP/1.1 404
78.153.140.151 - - [10/May/2025:23:43:50 +0000] GET /config/config.js HTTP/1.1 404
Exposed files can lead to significant data breaches. Examples of data exposed by improperly secured files include:
.env
Files: Often contain sensitive environment variables, such as database credentials, API keys, and secret tokens. Exposure can lead to unauthorized database access and API exploitation.config.json
, config.js
- Reveal internal configurations, server endpoints, and potentially even debugging flags or developer comments..bak
, .old
, .backup
may contain older versions of the application, including sensitive data that is no longer in use but still valuable to attackers.Securing web applications requires strict adherence to secure development practices:
/config/
, /admin/
, /staging/
), ensuring that only essential files are publicly accessible..env
, config.json
, /admin/test
)..env
, config.json
, and admin/test
within a short timeframe.Preventing file exposure in web environments requires a comprehensive approach, combining secure development practices, strict access controls, regular audits, and vigilant log monitoring. By understanding the techniques attackers use and the specific files they target, developers and security professionals can effectively mitigate risks and protect sensitive data from unauthorized access.