Hacking Net Applications - PenTestSummit - James Jardine
Hacking Net Applications - PenTestSummit - James Jardine
Hacking Net Applications - PenTestSummit - James Jardine
ASP.Net:
Tips
and
Tricks
James
Jardine
[email protected]
(866)
404-7837
@JardineSoEware
James
Jardine
Principal
Security
Consultant
at
Secure
Ideas
.Net
Developer
Since
the
Beta
Release
SANS
Instructor
and
Author
Dev544:
Secure
Coding
in
.Net
Podcaster
Blogs
Topics
ASP.Net
RequestValida_on
ViewState
EventValida_on
GET/POST
&
Postback
Conclusion
ASP.Net
Versions
1.1
2.0
3.0
3.5
4.0
4.5
*
Edi+ons
WebForms
MVC
Web
Pages
Web
API
WCF
Tes_ng
ASP.Net
Similar
to
other
technologies
GETs/POSTs,
etc
AJAX
Cookies,
Hidden
Fields,
Forms
Session
State,
Authen_ca_on
Dieren_ators
Request
Valida_on
View
State
Event
Valida_on
Other
Built
In
Controls
2013
Secure
Ideas
LLC
|
www.secureideas.com
Request
Valida_on
AOempt
to
block
XSS
AOacks
In
2.0+
only
works
for
HTML
Context
<[char],
<!,
<?,
</,
&#
Not
Really!
If
database
stores
data
as
varchar
(not
nvarchar)
Use
unicode-wide
%uFF1C
(<)
RequestValida_on
doesn't
detect
this
but...
10
10
ViewState
Base64
Encoded
By
Default
Can
be
encrypted
Vulnerabili_es
Parameter
Tampering,
XSS,
Info
Leakage
11
11
ViewState
Manipula_on
ViewStateViewer
-
hOp://labs.neohapsis.com/
2009/08/03/viewstateviewer-a-gui-tool-for-
deserializingreserializing-viewstate/
12
12
ViewState - Protected
13
13
The
Problem
This
is
wrong
common
advice!!
hOp://www.codeproject.com/Ques_ons/464873/Valida_on-of-viewstate-MAC-failed
2013
Secure
Ideas
LLC
|
www.secureideas.com
14
14
ViewStateMac
Provides
Tamper
Protec_on
for:
ViewState
EventValida_on
Web.Cong
<pages
enableViewStateMac="true"/>
Page
Level
<%@
Page
Language="C#"
EnableViewStateMac="true"...
2013
Secure
Ideas
LLC
|
www.secureideas.com
15
15
Event Valida_on
16
16
17
17
https://github.com/hacktics/vehicle
18
18
EventValida_on
Cong
Set
in
the
Web.Cong
File
<system.web>
<pages
enableEventValida+on="true"
/>
</system.web>
Set
at
the
Page
Level
<%@
EnableEventValida+on="true"
%>
19
19
20
20
ViewStateUserKey
Protects against Cross Site Request Forgery
Provides a user "salt" to ViewStateMac
Recommendation:
21
21
Postback
Webforms
are
based
around
"Postbacks"
Caused
by
Events
(ex.
buOon_click)
Triggered
by
__ViewState
or
__EventTarget
if
(!Page.IsPostback){
//
Authoriza_on/Populate
Data
lblCopy.Text
=
"copy
2013";
if(!User.IsInRole("Admin"))
Response.Redirect("Unauthorized.aspx");
}
else{
//
Execute
Events
}
22
22
Postback
AOacks
Authoriza_on
Bypass
if(!User.IsInRole("Admin"))
Response.Redirect("Unauthorized.aspx");
Recommenda_on:
Check
Authoriza_on
on
Every
Request
Recommenda_on:
Enable
ViewStateMac
Set
text
on
every
request
2013
Secure
Ideas
LLC
|
www.secureideas.com
23
23
GET/POST
Exchange
Server
Control
GETs
and
POSTs
are
Interchangeable
TextBox
ListBox
ViewState/EventValida_on
Etc.
24
24
GET/POST
Fix
WebForms
if(Request.RequestType
==
"POST")
MVC
[HTTPPost]
void
DoSomething()
25
25
Authen_ca_on
Cookie
HTTPOnly
(Hard
Coded)
Secure
Flag
may
not
be
set
Some_mes
there
is
an
error
if
behind
a
Load
Balancer
that
strips
SSL
Should
Recommend
Manually
seng
this
value
26
26
Misc.
Files
Trace.axd
Elmah.axd
Use
URL
Authoriza_on
in
the
Web.cong
Web.cong
(crown
jewels)
GOOD
LUCK!!
IIS
is
set
up
to
not
serve
this
le
27
27
Conclusion
ASP.Net
has
good
security
features
You
have
to
understand
them
ViewStateMac
is
IMPORTANT!
EventValida_on
ViewState
ViewStateUserKey
28
28
Hacking
ASP.Net:
Tips
and
Tricks
James
Jardine
[email protected]
(866)
404-7837
@JardineSoEware