Introduction To IIS and HTTP
Introduction To IIS and HTTP
2019
Web Server
separate product for NT 4.0 (IIS 4.0)
• supports TLS/SSL with Schannel
• metabase binary configuration database (LDAP compliant)
first integrated within Windows 2000 (IIS 5.0)
• no direct support for ASP.NET
• limited application isolation (service or individual worker process)
integrated with HTTP.SYS in Windows 2003 (IIS 6.0)
• first XML editing of metabase
• application pools and ASP.NET integration
• shared content storage
strictly XML configuration in Windows 2008 (IIS 7.0)
• HTTPS in kernel mode
• modular architecture and request pipeline
• request filtering
• installation with ServerManagerCmd.exe
• kernel mode authentication, AppPoolIdentity
• IIS Management Service
• non-Windows FTP accounts
• shared configuration storage
• URL rewrite module
1
27. 5. 2019
Web Server
slightly improved in Windows 2008 R2 (IIS 7.5)
• Schannel supports AES, SHA2
• complex and scriptable request filtering
• WebDAV extension
• full installation with PowerShell
• support for managed service accounts
• FTPS
security improved in Windows 2012 (IIS 8.0)
• TLS SNI for multiple certificates on a single IP address
• binding TLS certificates from a central PFX share
• support for group managed service accounts
• dynamic IP restrictions (DoS, x-forwarded-for)
• CPU limits per application pool
• FTP account lockout
minor improvements in Windows 2012 R2 (IIS 8.5)
• certificate rebind when renewed
• logging custom fields
minor improvements in Windows 2016 (IIS 10)
• wildcard hostheaders
• running on Nano Server
• HTTP/2
• powershell cmdlets shadowing appcmd
Reporting Services
IPHTTPS
WinRM
SSTP
IIS
Certificate
HTTP.SYS
Kernel Mode
2
27. 5. 2019
HTTP.SYS
NETSH http show servicestate
Installation
3
27. 5. 2019
4
27. 5. 2019
5
27. 5. 2019
HTTP
Web1
Browser \\FS
Browser
client \\FS
Browser
client https://finance config
client config
LB LB IP Web2
device
GUI web
GUI web
service content switch
service \\FS
client \\FS
client http proxy content
content
Web3
DB
DB
6
27. 5. 2019
Web1
Browser \\FS
Browser
client \\FS
Browser
client Client
https://finance config
client IP config
LB
Web2
device
GUI web
GUI web
service
service
Client NLB ethernet switch \\FS
client IP
\\FS
client content
content
Web3
DB
DB
Web Site
7
27. 5. 2019
HTTP Methods
GET
HEAD
POST
8
27. 5. 2019
GET
• URL (URI) encoded form parameters
• ?, #
• bookmarks, history, refresh + reenter
POST
• might have URL (URI) encoded parameters as well
• mostly included inside request body
• cannot bookmark, no history, invisible in the address bar, F5
asks to resend
URL examples
http://web10/default.aspx
• not an FQDN, cannot be resolved from internet
https://web10.gopas.cz/default.aspx
• using FQDN, might be resolvable from internet
file://C:\MyPages\test.htm
• local file only
file://\\fileserver\WebPages\test.htm
9
27. 5. 2019
Static file
• must have MIME type defined
Default document
• if not any present, tries Directory Browsing, or HTTP 403
Directory browsing
• if no explicit URL is specified, generates HTML with
directory listing
10
27. 5. 2019
Virtual Directories
Folder structure from URL perspective
200 OK
30x redirect
• temporary, permanent, method, not modified
40x client error
• unauthorized, forbidden, bad request
50x server error
• internal error, overloaded temporarily, gateway timeout
11
27. 5. 2019
MIME/content types
text/html
image/jpeg
image/png
.doc = application/msword
.docx = application/vnd.openxmlformats-
officedocument.wordprocessingml.document
application/pdf
12
27. 5. 2019
Logging
13
27. 5. 2019
HTTP.SYS tracing
14
27. 5. 2019
15
27. 5. 2019
Dynamic content
16
27. 5. 2019
<configuration>
<system.web>
<customErrors mode="On|Off|RemoteOnly" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
17
27. 5. 2019
W3WP.exe
WAS Service
W3SVC Sevice
W3WP.exe
W3WP.exe
ASP.NET
.config queue
ASP.NET
queue ASP.NET
queue
.config
TCPIP.SYS HTTP.SYS
HTTP.SYS
queue
Kernel Mode
18
27. 5. 2019
AppPool
recycling
and
Rapid Fail
Protection
IISRESET
+ /noforce
19
27. 5. 2019
Limits
TCP/IP stack driver limit
• HKLM\System\CurrentControlSet\Service\TCPIP\Parameters
TcpNumConnections = DWORD = 0 - 16 777 214
Limits
Web site limits
• http.sys
Apppool limit
• http.sys
20
27. 5. 2019
Limits
ASP.NET limits
• httpRuntime - executionTimeout
Limits
ASP.NET limits
• machine.config
• processModel – maxWorkerThreads, maxIoThreads
21
27. 5. 2019
http://finance \\FSFinance
G:\IIS\finance
http://warehouse account
account
DB_Warehouse
\\FSWarehouse
G:\IIS\warehouse
Isolation
Domain Account Network Groups Local Network Kerberos OS
Password Isolation Isolation PAC
Validation
22
27. 5. 2019
AppPool identity
# on DC
New-AdServiceAccount
-Name web-finance
–DnsHostName finance.gopas.virtual
–PrincipalsAllowedToRetrieveManagedPassword gps-wfe1$,gps-wfe2$
# on each WFE
Add-WindowsFeature RSAT-AD-PowerShell
Install-AdServiceAccount
23
27. 5. 2019
HTTP authentication
HTTP authentication
• no logoff
• Windows offers SSO
Cookie-based application authentication with forms-
based logon page
• smaller network footprint than Kerberos
• cookie expiration
• cookie sharing with state server
HTTP authentication
Name Type SSO Windows Third party
24
27. 5. 2019
http://portal
*.gopas.virtual
25
27. 5. 2019
Kerberos
AppPool user/comuters account
• System, Network Service, AppPoolIdentity
• domain user account
servicePrincipalName
• http/portal
• http/portal.gopas.virtual
26
27. 5. 2019
Forms authentication
Plain-text authentication
Cookies based further access
• expiration in the browser
• expiration on the server
• explicit log-out available
Customizable user interface
Implemented in ASP.NET code logic
• might be exposed in GUI or might not
HTTP cookies
27
27. 5. 2019
Configuration storage
<location >
%windir%\System32\inetsrv\Config applicationHost.config
%webRoot% web.config
%webRoot%\SubFolder web.config
%webRoot%\SubFolder web.config
%webRoot%\SubFolder web.config
<location >
Configuration storage
<location >
%windir%\System32\inetsrv\Config applicationHost.config
%windir%\Microsoft.NET\Framework64\v2.0…\Config machine.config
%windir%\Microsoft.NET\Framework64\v4.0…\Config machine.config
%windir%\Microsoft.NET\Framework64\v2.0…\Config Web.config
%windir%\Microsoft.NET\Framework64\v4.0…\Config web.config
%webRoot% web.config
%webRoot%\SubFolder web.config
%webRoot%\SubFolder web.config
%webRoot%\SubFolder web.config
<location >
28
27. 5. 2019
Request blocking
Windows Firewall
• source IP addresses
IP address and domain name restrictions
• IP address/range/network
• domain names require DNS PTR reverse lookup
• Proxy mode on Windows 2012+
Dynamic IP restrictions
• logging only mode: sc-status = 200, sc-substatus = 502
Request filtering (no regex)
• extensions, size of URL and payload, methods, URL pattern,
query string pattern, hidden segment (/segment/ or /file.name
exactly), header patterns and patterns by .ext (the Rules)
• use Hidden segments in collisions like /bin/ and /binary/ to block
"bin" sequence
http://portal/username.aspx
http://%70 %6F %72 %74 %61 %6C /username.aspx
http://%25 %37 %30 %25 %36 %46 %25 %37 %32
%25 %37 %34 %25 %36 %31 %25 %36 %43
/username.aspx
29
27. 5. 2019
Blocked
Client IP
Client
Web
30
27. 5. 2019
Blocked
Client IP
Client
Proxy
IP
Proxy Web
Blocked
Client IP
Client
Proxy
IP
31
27. 5. 2019
32
27. 5. 2019
Secure / insecure
Insecure
• SSL 2.0, SSL 3.0
• DES, MDx, SHA1, RC4
Must have for compatibility reasons
• TLS 1.0
Good
• TLS 1.1, TLS 1.2, …
certificates
• must contain Subject Alternative Name (SAN)
• all names must be present in SAN
• public CAs do not issue non-public DNS domains
33
27. 5. 2019
34
27. 5. 2019
HKLM\System\CurrentControlSet\Control\SecurityPro
viders \SCHANNEL\Protocols
• \PCT 1.0
• \SSL 2.0
\Client
– Enabled = DWORD = 0
\Server
– Enabled = DWORD = 0
• \SSL 3.0
\Client …
HKLM\System\CurrentControlSet\Control\SecurityPro
viders \SCHANNEL\Protocols
• \TLS 1.1
• \TLS 1.2
\Client
– Enabled = DWORD = 1
– DisabledByDefault = DWORD = 0
\Server
– Enabled = DWORD = 1
– DisabledByDefault = DWORD = 0
35
27. 5. 2019
Automatic (re)binding
PowerShell (re)binding
$serverName = 'portal'
dir Cert:\LocalMachine\My | ? {
($_.Issuer -ne $_.Subject) -and
($_.DnsNameList -contains $serverName) -and
($_.NotBefore -lt [DateTime]::Now) -and
($_.NotAfter -gt [DateTime]::Now) -and
($_.HasPrivateKey) -and
(-not $_.Archived) -and
($_.Extensions['2.5.29.37'].EnhancedKeyUsages['1.3.6.1.5.5.7.3.1'] -ne $null) } |
Sort -Desc NotAfter | Select -First 1
36
27. 5. 2019
TLS_RSA_WITH_RC4_128_MD5
TLS_RSA_WITH_RC4_128_SHA
TLS_RSA_WITH_3DES_EDE_CBC_SHA
TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
TLS_RSA_WITH_DES_CBC_SHA
TLS_DHE_DSS_WITH_DES_CBC_SHA
TLS_RSA_EXPORT1024_WITH_RC4_56_SHA
TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA
TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA
TLS_RSA_EXPORT_WITH_RC4_40_MD5
TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
TLS_RSA_WITH_NULL_MD5
TLS_RSA_WITH_NULL_SHA
SSL_RSA_WITH_RC4_128_SHA
SSL_RSA_WITH_3DES_EDE_CBC_SHA
SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
SSL_RSA_WITH_RC4_128_MD5
37
27. 5. 2019
TLS_RSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_P384
TLS_RSA_WITH_AES_128_CBC_SHA TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA_P256
TLS_RSA_WITH_AES_256_CBC_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA_P384
TLS_RSA_WITH_AES_256_CBC_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
TLS_RSA_WITH_RC4_128_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_3DES_EDE_CBC_SHA TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256 TLS_DHE_DSS_WITH_AES_256_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P384 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256 TLS_RSA_WITH_RC4_128_MD5
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P384 SSL_CK_RC4_128_WITH_MD5
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256 SSL_CK_DES_192_EDE3_CBC_WITH_MD5
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384 TLS_RSA_WITH_NULL_SHA256
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_P256 TLS_RSA_WITH_NULL_SHA
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256_P256
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA384_P384 SSL_RSA_WITH_RC4_128_SHA
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA384_P384 SSL_RSA_WITH_3DES_EDE_CBC_SHA
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_P256 SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA
SSL_RSA_WITH_RC4_128_MD5
http://www.ssllabs.com
38
27. 5. 2019
Redirects
39
27. 5. 2019
Server
Client
Location: HTTPS://www.gopas.cz/uri.htm
HTTP 200 OK
HTML: …
Server
Client
<a href="https://www.gopas.cz/link1.htm>
<a href="https://www.gopas.cz/link2.htm>
<img src="https://www.gopas.cz/pic1.png>
40
27. 5. 2019
Certificate
Attacker
Server
Client
HTTP HTTPS
Strict-Transport-Security (HSTS)
HTTP 200 OK
HTML: …
Server
Client
Strict-Transport-Security: max-age=360;
includeSubDomains;
<a href="https://www.gopas.cz/link2.htm>
<img src="https://www.gopas.cz/pic1.png>
Cache
HTTPS GET /link1.htm
Host: www.gopas.cz
41
27. 5. 2019
Server Certificate
www.gopas.cz
TLS tunnel
IP : Port IP: 10.10.0.37:443
WebSite
Client
Server Certificate
www.gopas.cz
TLS tunnel
IP : Port IP: 10.10.0.37:443
Website
Host: www.gopas.cz
Website
42
27. 5. 2019
Server Certificate
*.gopas.cz
TLS tunnel
IP : Port IP: 10.10.0.37:443
Website
HTTP GET /uri.htm
Client
Host: www.gopas.cz
Website
HTTP GET /uri.htm
Host: kurzy.gopas.cz
Server Certificate
TLS tunnel www.gopas.cz
IP : Port : Host
Website
IP: 10.10.0.37:443
HTTP GET /uri.htm
Client
Host: www.gopas.cz
Website
43
27. 5. 2019
Web1
https://www.gopas.cz
Browser \\FS
Browser
client IP2 \\FS
Browser
client Client
https://bi config
client IP1:Port1 IP NLB config
NLB
ethernet Web2
switch
GUI web
GUI web
service
service Client NLB ethernet switch \\FS
client IP2:Port2 \\FS
client content
content
Web3
IP3
IP NLB
DB
DB
NLB notes #1
44
27. 5. 2019
45
27. 5. 2019
46
27. 5. 2019
47
27. 5. 2019
PHP integration
install PHP
• download PHP
• download VC 201x redistributable
Add-WindowsFeatures Web-CGI
register Handle Mapping per site
• *.php -> PHP-CGI.exe
allow the PHP-CGI.exe in server CGI restrictions
PHP integration
48
27. 5. 2019
PHP integration
49