rhel 6
format weakness #22

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.

 		  "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))
	{
	    destroyFunctionData (data);
	    return 0;
	}

	if (!addFetchOpToFunctionData (data, "output", "offset.yxzz", target))
	{
	    destroyFunctionData (data);
	    return 0;
	}

	snprintf (str, 1024,

		  /* normal dot lightdir, this should eventually be
		     changed to a real light vector */
		  "DP3 bump, normal, { 0.707, 0.707, 0.0, 0.0 };"
		  "MUL bump, bump, state.light[0].diffuse;");

	if (!addDataOpToFunctionData (data, str))
	{
	    destroyFunctionData (data);
	    return 0;
	}

	if (!addColorOpToFunctionData (data, "output", "output"))
	{
	    destroyFunctionData (data);
	    return 0;
	}

	snprintf (str, 1024,

		  /* diffuse per-vertex lighting, opacity and brightness
		     and add lightsource bump color */
		  "ADD output, output, bump;");

	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.