SWEN-331: Engineering Secure Software Benjamin S Meyers
VOTD: Log Neutralization
Engineering Secure Software
Last Revised: September 2, 2020 1
VOTD: Log Neutralization Engineering Secure Software Last Revised: - - PowerPoint PPT Presentation
VOTD: Log Neutralization Engineering Secure Software Last Revised: September 2, 2020 SWEN-331: Engineering Secure Software Benjamin S Meyers 1 What is Log Neutralization? If you allow newlines ( \n ) in your log entries, then attackers
SWEN-331: Engineering Secure Software Benjamin S Meyers
Last Revised: September 2, 2020 1
SWEN-331: Engineering Secure Software Benjamin S Meyers
2
SWEN-331: Engineering Secure Software Benjamin S Meyers
3
$ java ArgumentLogger $'a normal event\nApr 25, 2012 1:26:19 PM ArgumentLogger main\nWARN: Attack suspected at 129.21.208.62' Sep 02, 2020 9:05:58 AM ArgumentLogger main // REAL INFO: a normal event // FAKE Apr 25, 2012 1:26:19 PM ArgumentLogger main // FAKE WARN: Attack suspected at 129.21.208.62 // REAL $ java ArgumentLogger --safe $'a normal event\nApr 25, 2012 1:26:19 PM ArgumentLogger main\nWARN: Attack suspected at 129.21.208.62' Sep 02, 2020 9:06:29 AM ArgumentLogger main INFO: a normal event_Apr 25, 2012 1:26:19 PM ArgumentLogger main_WARN: Attack suspected at 129.21.208.62
SWEN-331: Engineering Secure Software Benjamin S Meyers
4
public class ArgumentLogger { private static Logger log = Logger.getLogger(ArgumentLogger.class.getName()); public static void main(String[] args) { System.out.println("Logging commandline arguments:"); if (args.length > 0) { // Log safely if (args[0].equals("--safe") && args.length > 1) { System.out.println("Safe mode enabled."); // Encode carriage returns to avoid log forgery String clean = args[1].replace('\n', '_').replace('\r', '_'); log.info(clean); // Log unsafely } else { log.info(args[0]); } } } }
SWEN-331: Engineering Secure Software Benjamin S Meyers
5
SWEN-331: Engineering Secure Software Benjamin S Meyers
6
SWEN-331: Engineering Secure Software Benjamin S Meyers
7