CVE-2009-0040 - Improper Control of Generation of Code ('Code Injection')

Severity

68%

Complexity

86%

Confidentiality

106%

The PNG reference library (aka libpng) before 1.0.43, and 1.2.x before 1.2.35, as used in pngcrush and other applications, allows context-dependent attackers to cause a denial of service (application crash) or possibly execute arbitrary code via a crafted PNG file that triggers a free of an uninitialized pointer in (1) the png_read_png function, (2) pCAL chunk handling, or (3) setup of 16-bit gamma tables.

The PNG reference library (aka libpng) before 1.0.43, and 1.2.x before 1.2.35, as used in pngcrush and other applications, allows context-dependent attackers to cause a denial of service (application crash) or possibly execute arbitrary code via a crafted PNG file that triggers a free of an uninitialized pointer in (1) the png_read_png function, (2) pCAL chunk handling, or (3) setup of 16-bit gamma tables.

CVSS 2.0 Base Score 6.8. CVSS Attack Vector: network. CVSS Attack Complexity: medium. CVSS Vector: (AV:N/AC:M/Au:N/C:P/I:P/A:P).

Demo Examples

Improper Control of Generation of Code ('Code Injection')

CWE-94

This example attempts to write user messages to a message file and allow users to view them.


               
}
echo "Message Saved!<p>\n";
include($MessageFile);

While the programmer intends for the MessageFile to only include data, an attacker can provide a message such as:


               
message=%3C?php%20system(%22/bin/ls%20-l%22);?%3E

which will decode to the following:


               
<?php system("/bin/ls -l");?>

The programmer thought they were just including the contents of a regular data file, but PHP parsed it and executed the code. Now, this code is executed any time people view messages.

Notice that XSS (CWE-79) is also possible in this situation.

Improper Control of Generation of Code ('Code Injection')

CWE-94

edit-config.pl: This CGI script is used to modify settings in a configuration file.


               
}
# code to add a field/key to a file goes here
# code to set key to a particular file goes here
# code to delete key from a particular file goes here
eval($code);# this is super-efficient code, especially if you have to invoke# any one of dozens of different functions!
handleConfigAction($configfile, param('action'));
print "No action specified!\n";

The script intends to take the 'action' parameter and invoke one of a variety of functions based on the value of that parameter - config_file_add_key(), config_file_set_key(), or config_file_delete_key(). It could set up a conditional to invoke each function separately, but eval() is a powerful way of doing the same thing in fewer lines of code, especially when a large number of functions or variables are involved. Unfortunately, in this case, the attacker can provide other values in the action parameter, such as: add_key(",","); system("/bin/ls"); This would produce the following string in handleConfigAction(): config_file_add_key(",","); system("/bin/ls"); Any arbitrary Perl code could be added after the attacker has "closed off" the construction of the original function call, in order to prevent parsing errors from causing the malicious eval() to fail before the attacker's payload is activated. This particular manipulation would fail after the system() call, because the "_key(\$fname, \$key, \$val)" portion of the string would cause an error, but this is irrelevant to the attack because the payload has already been activated.

Overview

Type

libpng

First reported 16 years ago

2009-02-22 22:30:00

Last updated 6 years ago

2018-10-11 20:59:00

Affected Software

libpng 0.89c

0.89c

libpng 0.95

0.95

libpng 1.0.0

1.0.0

libpng 1.0.1

1.0.1

libpng 1.0.2

1.0.2

libpng 1.0.3

1.0.3

libpng 1.0.5

1.0.5

libpng 1.0.6

1.0.6

libpng 1.0.7

1.0.7

libpng 1.0.8

1.0.8

libpng 1.0.9

1.0.9

libpng 1.0.10

1.0.10

libpng 1.0.11

1.0.11

libpng 1.0.12

1.0.12

libpng 1.0.13

1.0.13

libpng 1.0.14

1.0.14

libpng 1.0.15

1.0.15

libpng 1.0.16

1.0.16

libpng 1.0.17

1.0.17

libpng 1.0.18

1.0.18

libpng 1.0.19

1.0.19

libpng 1.0.20

1.0.20

libpng 1.0.21

1.0.21

libpng 1.0.22

1.0.22

libpng 1.0.23

1.0.23

libpng 1.0.24

1.0.24

libpng 1.0.25

1.0.25

libpng 1.0.26

1.0.26

libpng 1.0.27

1.0.27

libpng 1.0.28

1.0.28

libpng 1.0.29

1.0.29

libpng 1.0.30

1.0.30

libpng 1.0.31

1.0.31

libpng 1.0.32

1.0.32

libpng 1.0.33

1.0.33

libpng 1.0.34

1.0.34

libpng 1.0.35

1.0.35

libpng 1.0.37

1.0.37

libpng 1.0.38

1.0.38

libpng 1.0.39

1.0.39

libpng 1.0.40

1.0.40

libpng 1.0.41

1.0.41

libpng 1.2.0

1.2.0

libpng 1.2.1

1.2.1

libpng 1.2.2

1.2.2

libpng 1.2.3

1.2.3

libpng 1.2.4

1.2.4

libpng 1.2.5

1.2.5

libpng 1.2.6

1.2.6

libpng 1.2.7

1.2.7

libpng 1.2.8

1.2.8

libpng 1.2.9

1.2.9

libpng 1.2.10

1.2.10

libpng 1.2.11

1.2.11

libpng 1.2.13

1.2.13

libpng 1.2.14

1.2.14

libpng 1.2.15

1.2.15

libpng 1.2.16

1.2.16

libpng 1.2.17

1.2.17

libpng 1.2.18

1.2.18

libpng 1.2.19

1.2.19

libpng 1.2.20

1.2.20

libpng 1.2.21

1.2.21

libpng 1.2.22

1.2.22

libpng 1.2.23

1.2.23

libpng 1.2.24

1.2.24

libpng 1.2.25

1.2.25

libpng 1.2.26

1.2.26

libpng 1.2.27

1.2.27

libpng 1.2.28

1.2.28

libpng 1.2.29

1.2.29

libpng 1.2.30

1.2.30

libpng 1.2.31

1.2.31

libpng 1.2.32

1.2.32

libpng 1.2.33

1.2.33

libpng 1.2.34

1.2.34

References

ftp://ftp.simplesystems.org/pub/png/src/libpng-1.2.34-ADVISORY.txt

Vendor Advisory

http://downloads.sourceforge.net/libpng/libpng-1.2.34-ADVISORY.txt

APPLE-SA-2009-08-05-1

APPLE-SA-2009-06-08-1

APPLE-SA-2009-06-17-1

APPLE-SA-2009-05-12

SUSE-SR:2009:005

SUSE-SA:2009:012

SUSE-SA:2009:023

[security-announce] 20090820 VMSA-2009-0010 VMware Hosted products update libpng and Apache HTTP Server

33970

Vendor Advisory

33976

Vendor Advisory

34137

34140

34143

34145

34152

34210

34265

34272

34320

34324

34388

34462

34464

35074

35258

35302

35379

35386

36096

GLSA-200903-28

GLSA-201209-25

SSA:2009-083-02

SSA:2009-083-03

[png-mng-implement] 20090219 libpng-1.2.35 and libpng-1.0.43 fix security vulnerability

http://sourceforge.net/project/shownotes.php?group_id=1689&release_id=662441

259989

1020521

http://support.apple.com/kb/HT3549

http://support.apple.com/kb/HT3613

http://support.apple.com/kb/HT3639

http://support.apple.com/kb/HT3757

http://support.avaya.com/elmodocs2/security/ASA-2009-069.htm

http://support.avaya.com/elmodocs2/security/ASA-2009-208.htm

http://support.avaya.com/japple/css/japple?temp.documentID=366362&temp.productID=154235&temp.releaseID=361845&temp.bucketID=126655&PAGE=Document

http://wiki.rpath.com/Advisories:rPSA-2009-0046

DSA-1750

DSA-1830

VU#649212

US Government Resource

MDVSA-2009:051

MDVSA-2009:075

MDVSA-2009:083

RHSA-2009:0315

RHSA-2009:0325

RHSA-2009:0333

RHSA-2009:0340

20090312 rPSA-2009-0046-1 libpng

20090529 VMSA-2009-0007 VMware Hosted products and ESX and ESXi patches resolve security issues

20090821 VMSA-2009-0010 VMware Hosted products update libpng and Apache HTTP Server

33827

33990

TA09-133A

US Government Resource

TA09-218A

US Government Resource

http://www.vmware.com/security/advisories/VMSA-2009-0007.html

ADV-2009-0469

ADV-2009-0473

ADV-2009-0632

ADV-2009-1297

ADV-2009-1451

ADV-2009-1462

ADV-2009-1522

ADV-2009-1560

ADV-2009-1621

ADV-2009-2172

libpng-pointer-arrays-code-execution(48819)

oval:org.mitre.oval:def:10316

oval:org.mitre.oval:def:6458

FEDORA-2009-2045

FEDORA-2009-1976

FEDORA-2009-2882

FEDORA-2009-2884

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.