[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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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