11.07.2015 Views

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

Improving Web Application Security: Threats and - CGISecurity

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 10: Building Secure ASP.NET Pages <strong>and</strong> Controls 291Parameter ManipulationParameters, such as those found in form fields, query strings, view state, <strong>and</strong> cookies,can be manipulated by attackers who usually intend to gain access to restricted pagesor trick the application into performing an unauthorized operation.For example, if an attacker knows that you are using a weak authentication tokenscheme such as a guessable number within a cookie, the attacker can construct acookie with another number <strong>and</strong> make a request as a different (possibly privileged)user.The following recommendations help you avoid parameter manipulationvulnerabilities:● Protect view state with MACs.●●●Use Page.ViewStateUserKey to counter one-click attacks.Maintain sensitive data on the server.Validate input parameters.Protect View State with MACsIf your <strong>Web</strong> pages or controls use view state to maintain state across HTTP requests,ensure that the view state is encrypted <strong>and</strong> integrity checked through the use ofMACs. By default, the enableViewStateMac attribute on the element inMachine.config ensures that view state is protected with a MAC.Note The @Page directive also supports the preceding attributes, which allows you to customizesettings on a per-page basis.While you can override whether or not view state is enabled on a per-control, page,or application basis, make sure enableViewStateMac is set to true whenever you useview state.Server.TransferIf your application uses Server.Transfer as shown below <strong>and</strong> sets the optional secondBoolean parameter to true so that the QueryString <strong>and</strong> Form collections arepreserved, then the comm<strong>and</strong> will fail if enableViewStateMac is set to true.Server.Transfer("page2.aspx", true);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!