Commit b38ab79
XERCESC-2188 - Use-after-free on external DTD scan (CVE-2018-1311)
These are the instructions for observing the bug (before this commit):
$ git clone https://github.com/apache/xerces-c.git
$ cd xerces-c
$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
$ make -j8
$ cp ../samples/data/personal.xml .
$ cat <<EOF >personal.dtd
<?xml encoding="ISO-8859-1"?>
<!ENTITY % nonExistentEntity SYSTEM "non-existent.ent">
%nonExistentEntity;
EOF
$ gdb samples/StdInParse
(gdb) b IGXMLScanner.cpp:1544
(gdb) run <personal.xml
1544 fReaderMgr.pushReader(reader, declDTD);
(gdb) p declDTD
$1 = (xercesc_4_0::DTDEntityDecl *) 0x49ac68
(gdb) n
1547 dtdScanner.scanExtSubsetDecl(false, true);
(gdb) n
1548 }
(gdb) s
...
(gdb) s # The Janitor is about to delete the above declDTD.
90 delete fData;
(gdb) p fData
$1 = (xercesc_4_0::DTDEntityDecl *) 0x49ac68
(gdb) b ReaderMgr.cpp:1024
(gdb) n
...
(gdb) n # Now we about to dereference the deleted declDTD.
1024 if (curEntity && !curEntity->isExternal())
(gdb) p curEntity
$2 = (const xercesc_4_0::XMLEntityDecl *) 0x49ac681 parent 5b31900 commit b38ab79
File tree
4 files changed
+229
-82
lines changed- src/xercesc/internal
4 files changed
+229
-82
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | | - | |
1056 | 1055 | | |
1057 | 1056 | | |
1058 | 1057 | | |
1059 | 1058 | | |
1060 | 1059 | | |
1061 | | - | |
| 1060 | + | |
1062 | 1061 | | |
1063 | 1062 | | |
1064 | 1063 | | |
| |||
2131 | 2130 | | |
2132 | 2131 | | |
2133 | 2132 | | |
2134 | | - | |
2135 | 2133 | | |
2136 | 2134 | | |
2137 | 2135 | | |
2138 | 2136 | | |
2139 | 2137 | | |
2140 | | - | |
| 2138 | + | |
2141 | 2139 | | |
2142 | 2140 | | |
2143 | 2141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1535 | 1535 | | |
1536 | 1536 | | |
1537 | 1537 | | |
1538 | | - | |
1539 | 1538 | | |
1540 | 1539 | | |
1541 | 1540 | | |
1542 | 1541 | | |
1543 | 1542 | | |
1544 | | - | |
| 1543 | + | |
1545 | 1544 | | |
1546 | 1545 | | |
1547 | 1546 | | |
| |||
3098 | 3097 | | |
3099 | 3098 | | |
3100 | 3099 | | |
3101 | | - | |
3102 | 3100 | | |
3103 | 3101 | | |
3104 | 3102 | | |
3105 | 3103 | | |
3106 | 3104 | | |
3107 | | - | |
| 3105 | + | |
3108 | 3106 | | |
3109 | 3107 | | |
3110 | 3108 | | |
| |||
0 commit comments