rhel 6
format weakness #32

4

Weakness Breakdown


Definition:

A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always 0-terminate.

File Name:

compiz-0.8.2/plugins/water.c

Context:

The highlighted line of code below is the trigger point of this particular Red Hat Enterprise Linux 6 format weakness.

     for (function = ws->bumpMapFunctions; function; function = function->next)
    {
	if (function->param  == param &&
	    function->unit   == unit  &&
	    function->target == target)
	    return function->handle;
    }

    data = createFunctionData ();
    if (data)
    {
	static char *temp[] = { "normal", "temp", "total", "bump", "offset" };
	int	    i, handle = 0;
	char	    str[1024];

	for (i = 0; i < sizeof (temp) / sizeof (temp[0]); i++)
	{
	    if (!addTempHeaderOpToFunctionData (data, temp[i]))
	    {
		destroyFunctionData (data);
		return 0;
	    }
	}

	snprintf (str, 1024,

		  /* get normal from normal map */
		  "TEX normal, fragment.texcoord[%d], texture[%d], %s;"

		  /* save height */
		  "MOV offset, normal;"

		  /* remove scale and bias from normal */
		  "MAD normal, normal, 2.0, -1.0;"

		  /* normalize the normal map */
		  "DP3 temp, normal, normal;"
		  "RSQ temp, temp.x;"
		  "MUL normal, normal, temp;"

		  /* scale down normal by height and constant and use as
		     offset in texture */
		  "MUL offset, normal, offset.w;"
		  "MUL offset, offset, program.env[%d];",

		  unit, unit,
		  (ws->target == GL_TEXTURE_2D) ? "2D" : "RECT",
		  param);

	if (!addDataOpToFunctionData (data, str)) 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.