forked from appsecco/dvna
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
63 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,60 @@ | ||
# Insufficient Logging and Monitoring | ||
|
||
Logging. Logging. | ||
Exploitation of insufficient logging and monitoring is the bedrock of nearly every major incident. | ||
|
||
**Vulnerable Code snippet** | ||
- Auditable events, such as logins, failed logins, and high-value transactions are not logged. | ||
- Warnings and errors generate no, inadequate, or unclear log messages. | ||
- Logs of applications and APIs are not monitored for suspicious activity. | ||
- Logs are only stored locally. | ||
- Appropriate alerting thresholds and response escalation processes are not in place or effective. | ||
- Penetration testing and scans by DAST tools (such as OWASP ZAP) do not trigger alerts. | ||
- The application is unable to detect, escalate, or alert for active attacks in real time or near real time. | ||
|
||
*core/appHandler.js* | ||
``` | ||
... | ||
**Solution** | ||
|
||
All critical functionalities of the application must be logged. We use winston, a logging library to handle our logging. | ||
|
||
Define a default logger | ||
|
||
*server.js* | ||
```js | ||
var winston = require('winston') | ||
... | ||
winston.configure({ | ||
format: winston.format.json(), | ||
transports: [ | ||
new winston.transports.File({ filename: 'combined.log' }) | ||
] | ||
}); | ||
... | ||
``` | ||
**Solution** | ||
|
||
Log from anywhere | ||
|
||
*core/appHandler.js* | ||
``` | ||
*core/passport.js* | ||
```js | ||
var winston = requir('winston') | ||
... | ||
if (!isValidPassword(user, password)) { | ||
logger.log({level:'warn',message:'Failed login attempt for ', username}) | ||
return done(null, false, req.flash('danger', 'Invalid Credentials')) | ||
} | ||
... | ||
``` | ||
|
||
But it is recommended to explicitly validate/sanitize inputs | ||
|
||
**Fixes** | ||
|
||
Implemented in the following files | ||
|
||
- *core/appHandler.js* | ||
- *server.js* | ||
- *core/passport.js* | ||
- *core/authHandler.js* | ||
|
||
**Recommendation** | ||
|
||
- Validate Input before processing | ||
- Sanitize Input before storing | ||
- Log all sensitive operations by default | ||
- Ensure that the logs are stored and processed securely | ||
|
||
**Reference** | ||
|
||
- <https://www.owasp.org/index.php/Top_10-2017_A8-Insecure_Deserialization> | ||
- <https://www.owasp.org/index.php/Top_10-2017_A10-Insufficient_Logging%26Monitoring> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters