19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

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

712 Chapter 19 n Finding Vulnerabilities in Source Code<br />

Table 19-1: APIs Used to Acquire User-Supplied Data on <strong>the</strong> Java Platform<br />

API<br />

getParameter<br />

getParameterNames<br />

getParameterValues<br />

DESCRIPTION<br />

Parameters within <strong>the</strong> URL query string and <strong>the</strong> body<br />

of a POST request are stored as a map of String<br />

names to String values, which can be accessed<br />

using <strong>the</strong>se APIs.<br />

getParameterMap<br />

getQueryString<br />

getHeader<br />

getHeaders<br />

getHeaderNames<br />

getRequestURI<br />

getRequestURL<br />

getCookies<br />

getRequestedSessionId<br />

getInputStream<br />

getReader<br />

getMethod<br />

getProtocol<br />

getServerName<br />

getRemoteUser<br />

getUserPrincipal<br />

Returns <strong>the</strong> entire query string contained within <strong>the</strong><br />

request and can be used as an alternative to <strong>the</strong><br />

getParameter APIs.<br />

HTTP headers in <strong>the</strong> request are stored as a map<br />

of String names to String values and can be<br />

accessed using <strong>the</strong>se APIs.<br />

These APIs return <strong>the</strong> URL contained within <strong>the</strong><br />

request, including <strong>the</strong> query string.<br />

Returns an array of Cookie objects, which contain<br />

details of <strong>the</strong> cookies received in <strong>the</strong> request, including<br />

<strong>the</strong>ir names and values.<br />

Used as an alternative to getCookies in some<br />

cases; returns <strong>the</strong> session ID value submitted within<br />

<strong>the</strong> request.<br />

These APIs return different representations of <strong>the</strong><br />

raw request received from <strong>the</strong> client and <strong>the</strong>refore<br />

can be used to access any of <strong>the</strong> information<br />

obtained by all <strong>the</strong> o<strong>the</strong>r APIs.<br />

Returns <strong>the</strong> method used in <strong>the</strong> HTTP request.<br />

Returns <strong>the</strong> protocol used in <strong>the</strong> HTTP request.<br />

Returns <strong>the</strong> value of <strong>the</strong> HTTP Host header.<br />

If <strong>the</strong> current user is au<strong>the</strong>nticated, <strong>the</strong>se APIs return<br />

details of <strong>the</strong> user, including his login name. If users<br />

can choose <strong>the</strong>ir own username during self-registration,<br />

this may be a means of introducing malicious<br />

input into <strong>the</strong> <strong>application</strong>’s processing.<br />

Session Interaction<br />

Java Platform <strong>application</strong>s use <strong>the</strong> javax.servlet.http.HttpSession interface<br />

to store and retrieve information within <strong>the</strong> current session. Per-session storage<br />

is a map of string names to object values. The APIs listed in Table 19-2 are used<br />

to store and retrieve data within <strong>the</strong> session.

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

Saved successfully!

Ooh no, something went wrong!