<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Amwestgate</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Amwestgate"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Amwestgate"/>
		<updated>2026-05-28T07:40:31Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Logging_issues&amp;diff=16533</id>
		<title>Logging issues</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Logging_issues&amp;diff=16533"/>
				<updated>2007-02-19T16:45:56Z</updated>
		
		<summary type="html">&lt;p&gt;Amwestgate: bullet points added.  the formatting in this article can be improved.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[OWASP Code Review Guide Table of Contents]]__TOC__&lt;br /&gt;
=== In Brief===&lt;br /&gt;
Logging is the recording of information into storage that details who performed what and when they did it (like an audit trail) This can also cover debug messages implemented during development as well as any messages reflecting problems or states within the application. It should be an audit of everything that the business deems important to track about the applications use. Logging provides a detective method to ensure that the other security mechanisms being used are performing correctly. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logging should be at least done at the following events:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Authentication: Successful &amp;amp; unsuccessful attempts.&lt;br /&gt;
* Authorization requests.&lt;br /&gt;
* Data manipulation: Any (CUD) Create, Update, Delete actions performed on the application.&lt;br /&gt;
* Session activity: Termination/Logout events.&lt;br /&gt;
&lt;br /&gt;
A good logging strategy should include the recording of any errors that occur in the application.&amp;lt;br&amp;gt;&lt;br /&gt;
The application should have the ability to detect and record possible malicious use such as events that cause unexpected errors or defy the state model of the application. Users who attempt to get access to data that they shouldn’t (authorization), and incoming data that does not meet validation rules or has been tampered with. In general any error condition which could not occur without an attempt by the user to circumvent the application logic.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logging should give us the information required to form a proper audit trail of a users actions.&amp;lt;br&amp;gt; &lt;br /&gt;
Leading from this the date/time the actions were performed would be useful.&lt;br /&gt;
Logging functionality should not log a any personal or sensitive data pertaining to the user of function at hand that is being recorded; An example of this if your application is accepting HTTP GET the payload is in the URL and the GET shall be loged. This may result in logging sensitive data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logging should follow best practice regarding data validation; maximum length of information, malicious characters….&amp;lt;br&amp;gt;&lt;br /&gt;
We should ensure that logging functionality only log’s messages of a reasonable length and that this length is enforced.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Common open source logging solutions:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Log4J:		 http://logging.apache.org/log4j/docs/index.html&lt;br /&gt;
&lt;br /&gt;
 Log4net:	 http://logging.apache.org/log4net/&lt;br /&gt;
&lt;br /&gt;
 Commons Logging: http://jakarta.apache.org/commons/logging/index.html&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Tomcat(5.5), if no custom logger is defined (log4J) then everything is logged via Commons Logging and ultimately ends up in catalina.out.&amp;lt;br&amp;gt;&lt;br /&gt;
catalina.out grows endlessly and does not recycle/rollover. Log4J provides “Rollover” functionality, which limits the size of the log. Log4J also gives the option to specify “appenders” which can redirect the log data to other destinations such as a port, syslog or even a database or JMS.&lt;br /&gt;
&lt;br /&gt;
The parts of log4J which should be considered apart from the actual data being logged by the application are contained in the log4j.properties file:&lt;br /&gt;
&lt;br /&gt;
 #&lt;br /&gt;
 # Configures Log4j as the Tomcat system logger&lt;br /&gt;
 #&lt;br /&gt;
 &lt;br /&gt;
 #&lt;br /&gt;
 # Configure the logger to output info level messages into a rolling log file.&lt;br /&gt;
 #&lt;br /&gt;
 log4j.rootLogger=INFO, R&lt;br /&gt;
 &lt;br /&gt;
 #&lt;br /&gt;
 # To continue using the &amp;quot;catalina.out&amp;quot; file (which grows forever),&lt;br /&gt;
 # comment out the above line and uncomment the next.&lt;br /&gt;
 #&lt;br /&gt;
 #log4j.rootLogger=ERROR, A1&lt;br /&gt;
 &lt;br /&gt;
 #&lt;br /&gt;
 # Configuration for standard output (&amp;quot;catalina.out&amp;quot;).&lt;br /&gt;
 #&lt;br /&gt;
 log4j.appender.A1=org.apache.log4j.ConsoleAppender&lt;br /&gt;
 log4j.appender.A1.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
 #&lt;br /&gt;
 # Print the date in ISO 8601 format&lt;br /&gt;
 #&lt;br /&gt;
 log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n&lt;br /&gt;
 &lt;br /&gt;
 #&lt;br /&gt;
 # Configuration for a rolling log file (&amp;quot;tomcat.log&amp;quot;).&lt;br /&gt;
 #&lt;br /&gt;
 log4j.appender.R=org.apache.log4j.DailyRollingFileAppender&lt;br /&gt;
 log4j.appender.R.DatePattern='.'yyyy-MM-dd&lt;br /&gt;
 #&lt;br /&gt;
 # Edit the next line to point to your logs directory.&lt;br /&gt;
 # The last part of the name is the log file name.&lt;br /&gt;
 #&lt;br /&gt;
 log4j.appender.R.File=/usr/local/tomcat/logs/tomcat.log&lt;br /&gt;
 log4j.appender.R.layout=org.apache.log4j.PatternLayout&lt;br /&gt;
 #&lt;br /&gt;
 # Print the date in ISO 8601 format&lt;br /&gt;
 #&lt;br /&gt;
 log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n&lt;br /&gt;
 &lt;br /&gt;
 #&lt;br /&gt;
 # Application logging options&lt;br /&gt;
 #&lt;br /&gt;
 #log4j.logger.org.apache=DEBUG&lt;br /&gt;
 #log4j.logger.org.apache=INFO&lt;br /&gt;
 #log4j.logger.org.apache.struts=DEBUG&lt;br /&gt;
 #log4j.logger.org.apache.struts=INFO&lt;br /&gt;
&lt;br /&gt;
=== Vulnerable patterns examples for Logging===&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
The following are issues one may look out for or question the development team /deployment team.&lt;br /&gt;
Logging and auditing are detective methods of fraud prevention. Much overlooked in the industry, which enables attackers to continue to attack/commit fraud without being detected.&lt;br /&gt;
&lt;br /&gt;
They cover Windows and .NET issues:&lt;br /&gt;
'''Check that:'''&lt;br /&gt;
#Windows native log puts a timestamp on all log entries.&lt;br /&gt;
#GMT is set as the default time.&lt;br /&gt;
#The Windows operating system can be configured to use network timeservers.&lt;br /&gt;
#By default the event log will show: Name of the computer that generated the event; The application in the source field of the viewer. Additional information such as request identifier,username,and destination should be included in the body of the error event.&lt;br /&gt;
#No sensitive or business critical information is sent to the application logs.&lt;br /&gt;
#Application logs are not located in the web root directory.&lt;br /&gt;
#Log policy allows different levels of log severity.&lt;br /&gt;
&lt;br /&gt;
===== Writing to the Event Log=====&lt;br /&gt;
In the course of reviewing .NET code ensure that calls the EventLog object do not provide any confidential information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 EventLog.WriteEntry( &amp;quot;&amp;lt;password&amp;gt;&amp;quot;,EventLogEntryType.Information);&lt;br /&gt;
&lt;br /&gt;
====JAVA====&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Code Review Project]]&lt;/div&gt;</summary>
		<author><name>Amwestgate</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Command_Injection&amp;diff=16438</id>
		<title>Command Injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Command_Injection&amp;diff=16438"/>
				<updated>2007-02-12T16:00:40Z</updated>
		
		<summary type="html">&lt;p&gt;Amwestgate: Without the quotes, the shell command line interpretter handles the second command.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Attack}}&lt;br /&gt;
&lt;br /&gt;
==Abstract==&lt;br /&gt;
&lt;br /&gt;
Executing commands that include unvalidated user input can cause an application to act on behalf of an attacker.&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Command injection problems are a subset of injection problem, in which the process is tricked into calling external processes of the attackers choice through the injection of control-plane data into the data plane.&lt;br /&gt;
&lt;br /&gt;
Command injection attacks take two forms:&lt;br /&gt;
&lt;br /&gt;
* An attacker can change the command that the program executes: the attacker explicitly controls what the command is. &lt;br /&gt;
* An attacker can change the environment in which the command executes: the attacker implicitly controls what the command means. &lt;br /&gt;
&lt;br /&gt;
In this case we are primarily concerned with the first scenario, in which an attacker explicitly controls the command that is executed. Command injection vulnerabilities of this type occur when:&lt;br /&gt;
&lt;br /&gt;
# Data enters the application from an untrusted source. &lt;br /&gt;
# The data is part of a string that is executed as a command by the application. &lt;br /&gt;
# By executing the command, the application gives an attacker a privilege or capability that the attacker would not otherwise have. &lt;br /&gt;
&lt;br /&gt;
==Consequences ==&lt;br /&gt;
&lt;br /&gt;
*	Access control: Command injection allows for the execution of arbitrary commands and code by the attacker.&lt;br /&gt;
&lt;br /&gt;
==Exposure period ==&lt;br /&gt;
&lt;br /&gt;
*	Design: It may be possible to find alternate methods for satisfying functional requirements than calling external processes. This is minimal.&lt;br /&gt;
&lt;br /&gt;
*	Implementation: Exposure for this issue is limited almost exclusively to implementation time. Any language or platform is subject to this flaw.&lt;br /&gt;
&lt;br /&gt;
==Platform ==&lt;br /&gt;
&lt;br /&gt;
*	Language: Any&lt;br /&gt;
&lt;br /&gt;
*	Platform: Any&lt;br /&gt;
&lt;br /&gt;
==Required resources ==&lt;br /&gt;
&lt;br /&gt;
Any&lt;br /&gt;
&lt;br /&gt;
==Severity ==&lt;br /&gt;
&lt;br /&gt;
High&lt;br /&gt;
&lt;br /&gt;
==Likelihood   of exploit ==&lt;br /&gt;
&lt;br /&gt;
Very High&lt;br /&gt;
&lt;br /&gt;
==Avoidance and mitigation ==&lt;br /&gt;
&lt;br /&gt;
*	Design: If at all possible, use library calls rather than external processes to recreate the desired functionality&lt;br /&gt;
&lt;br /&gt;
*	Implementation: Ensure that all external commands called from the program are statically created, or - if they must take input from a user - that the input and final line generated are vigorously white-list checked.&lt;br /&gt;
&lt;br /&gt;
*	Run time: Run time policy enforcement may be used in a white-list fashion to prevent use of any non-sanctioned commands.&lt;br /&gt;
&lt;br /&gt;
==Discussion ==&lt;br /&gt;
&lt;br /&gt;
Command injection is a common problem with wrapper programs. Often, parts of the command to be run are controllable by the end user. If a malicious user injects a character (such as a semi-colon) that delimits the end of one command and the beginning of another, he may then be able to insert an entirely new and unrelated command to do whatever he pleases. &lt;br /&gt;
&lt;br /&gt;
The most effective way to deter such an attack is to ensure that the input provided by the user adheres to strict rules as to what characters are acceptable. As always, white-list style checking is far preferable to black-list style checking.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
&lt;br /&gt;
The following code is wrapper around the UNIX command ''cat'' which prints the contents of a file to standard out. It is also injectable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv) { &lt;br /&gt;
  char cat[] = &amp;quot;cat &amp;quot;;    &lt;br /&gt;
  char *command;    &lt;br /&gt;
  size_t commandLength;    &lt;br /&gt;
&lt;br /&gt;
  commandLength = strlen(cat) + strlen(argv[1]) + 1;    &lt;br /&gt;
  command = (char *) malloc(commandLength);    &lt;br /&gt;
  strncpy(command, cat, commandLength);    &lt;br /&gt;
  strncat(command, argv[1], (commandLength - strlen(cat)) );&lt;br /&gt;
&lt;br /&gt;
  system(command);    &lt;br /&gt;
  return (0);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Used normally, the output is simply the contents of the file requested:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./catWrapper Story.txt&lt;br /&gt;
When last we left our heroes...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, if we add a semicolon and another command to the end of this line, the command is executed by catWrapper with no complaint:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./catWrapper &amp;quot;Story.txt; ls&amp;quot;&lt;br /&gt;
When last we left our heroes...&lt;br /&gt;
Story.txt               doubFree.c              nullpointer.c&lt;br /&gt;
unstosig.c              www*                    a.out*&lt;br /&gt;
format.c                strlen.c                useFree*&lt;br /&gt;
catWrapper*             misnull.c               strlength.c                useFree.c               commandinjection.c      nodefault.c             trunc.c                 writeWhatWhere.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If catWrapper had been set to have a higher privilege level than the standard user, arbitrary commands could be executed with that higher privilege.&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
&lt;br /&gt;
The following simple program accepts a filename as a command line argument and displays the contents of the file back to the user. The program is installed setuid root because it is intended for use as a learning tool to allow system administrators in-training to inspect privileged system files without giving them the ability to modify them or damage the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	int main(char* argc, char** argv) {&lt;br /&gt;
		char cmd[CMD_MAX] = &amp;quot;/usr/bin/cat &amp;quot;;	&lt;br /&gt;
		strcat(cmd, argv[1]);&lt;br /&gt;
		system(cmd);	&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because the program runs with root privileges, the call to system() also executes with root privileges. If a user specifies a standard filename, the call works as expected. However, if an attacker passes a string of the form &amp;quot;;rm -rf /&amp;quot;, then the call to system() fails to execute cat due to a lack of arguments and then plows on to recursively delete the contents of the root partition.&lt;br /&gt;
&lt;br /&gt;
===Example 3=== &lt;br /&gt;
&lt;br /&gt;
The following code from a privileged program uses the environment variable $APPHOME to determine the application's installation directory and then executes an initialization script in that directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	...&lt;br /&gt;
	char* home=getenv(&amp;quot;APPHOME&amp;quot;); 	&lt;br /&gt;
	char* cmd=(char*)malloc(strlen(home)+strlen(INITCMD));&lt;br /&gt;
	if (cmd) { &lt;br /&gt;
		strcpy(cmd,home);&lt;br /&gt;
		strcat(cmd,INITCMD);&lt;br /&gt;
		execl(cmd, NULL);&lt;br /&gt;
	}&lt;br /&gt;
	...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As in Example 2, the code in this example allows an attacker to execute arbitrary commands with the elevated privilege of the application. In this example, the attacker can modify the environment variable $APPHOME to specify a different path containing a malicious version of INITCMD. Because the program does not validate the value read from the environment, by controlling the environment variable the attacker can fool the application into running malicious code.&lt;br /&gt;
&lt;br /&gt;
The attacker is using the environment variable to control the command that the program invokes, so the effect of the environment is explicit in this example. We will now turn our attention to what can happen when the attacker can change the way the command is interpreted.&lt;br /&gt;
&lt;br /&gt;
===Example 4===&lt;br /&gt;
&lt;br /&gt;
The code below is from a web-based CGI utility that allows users to change their passwords. The password update process under NIS includes running make in the /var/yp directory. Note that since the program updates password records, it has been installed setuid root.&lt;br /&gt;
&lt;br /&gt;
The program invokes make as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	system(&amp;quot;cd /var/yp &amp;amp;&amp;amp; make &amp;amp;&amp;gt; /dev/null&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unlike the previous examples, the command in this example is hardcoded, so an attacker cannot control the argument passed to system(). However, since the program does not specify an absolute path for make and does not scrub any environment variables prior to invoking the command, the attacker can modify their $PATH variable to point to a malicious binary named make and execute the CGI script from a shell prompt. And since the program has been installed setuid root, the attacker's version of make now runs with root privileges.&lt;br /&gt;
&lt;br /&gt;
The environment plays a powerful role in the execution of system commands within programs. Functions like system() and exec() use the environment of the program that calls them, and therefore attackers have a potential opportunity to influence the behavior of these calls.&lt;br /&gt;
&lt;br /&gt;
==Related problems ==&lt;br /&gt;
&lt;br /&gt;
* [[Injection problem]]&lt;br /&gt;
&lt;br /&gt;
==Related Threats==&lt;br /&gt;
&lt;br /&gt;
==Related Attacks==&lt;br /&gt;
&lt;br /&gt;
[[OS Command Injection]]&lt;br /&gt;
&lt;br /&gt;
==Related Vulnerabilities==&lt;br /&gt;
&lt;br /&gt;
==Related Countermeasures==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Input Validation]]&lt;br /&gt;
&lt;br /&gt;
==Categories==&lt;br /&gt;
&lt;br /&gt;
[[Category:Attack]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Injection Attack]]&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_CLASP_Project]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Design]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Input Validation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Code Snippet]]&lt;br /&gt;
&lt;br /&gt;
[[Category:C]]&lt;br /&gt;
&lt;br /&gt;
{{Template:SecureSoftware}}&lt;br /&gt;
{{Template:Fortify}}&lt;/div&gt;</summary>
		<author><name>Amwestgate</name></author>	</entry>

	</feed>