[Solved] Fortify Issue “Log Forging” and “Cross Site Script Injection” in log file


To fix fortify scan “Log Forging” or “Cross Site Script Injection” issue need to remove script tag before printing log message in console or log file.

Why?

If logs statement having script tag then open these logs over browser like kibana while analysis. The script or content inside the script tag can execute that cause “cross-site script injections”.

Solutions

Call this lines of code which below uses a regular expression to identify valid script tags and removes them from the message while leaving the script code between the starting and end tags.

Remove script tag from log string message

One thought on “[Solved] Fortify Issue “Log Forging” and “Cross Site Script Injection” in log file”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s