Xxe Cheat Sheet Github



REST (or REpresentational State Transfer) is an architectural style first described in Roy Fielding's Ph.D. dissertation on Architectural Styles and the Design of Network-based Software Architectures.

It evolved as Fielding wrote the HTTP/1.1 and URI specs and has been proven to be well-suited for developing distributed hypermedia applications. While REST is more widely applicable, it is most commonly used within the context of communicating with services via HTTP.

The key abstraction of information in REST is a resource. A REST API resource is identified by a URI, usually a HTTP URL. REST components use connectors to perform actions on a resource by using a representation to capture the current or intended state of the resource and transferring that representation.

In this section, we’ll explain what XML external entity injection is, describe some common examples, explain how to find and exploit various kinds of XXE injection, and summarize how to prevent XXE injection attacks. Extract 추가예정 parsestr 추가예정 parseurl 추가예정 pregreplace 추가예정 sprintf / vprintf 추가예정 temp files. 업로드되는 임시 첨부 파일, 세션 파일, wrapper 를 통한 필터 처리 중에 있는 임시 파일의 경우 본 저장경로와 /tmp 폴더에 쓰기 권한이 없으면, 현재 디렉터리에 임시 파일을 작성합니다. The commands below may not be enough for you to obtain your Offensive Security Certified Professional (OSCP). XXE Cheat Sheet - SecurityIdiots. GitHub Gist: instantly share code, notes, and snippets. 5 Deserialization Prevention Requirements. XXE Cheat Sheet - SecurityIdiots. Instantly share code, notes, and snippets.

The primary connector types are client and server, secondary connectors include cache, resolver and tunnel.

REST APIs are stateless. Stateful APIs do not adhere to the REST architectural style. State in the REST acronym refers to the state of the resource which the API accesses, not the state of a session within which the API is called. While there may be good reasons for building a stateful API, it is important to realize that managing sessions is complex and difficult to do securely.

Stateful services are out of scope of this Cheat Sheet: Passing state from client to backend, while making the service technically stateless, is an anti-pattern that should also be avoided as it is prone to replay and impersonation attacks.

In order to implement flows with REST APIs, resources are typically created, read, updated and deleted. For example, an ecommerce site may offer methods to create an empty shopping cart, to add items to the cart and to check out the cart. Each of these REST calls is stateless and the endpoint should check whether the caller is authorized to perform the requested operation.

Another key feature of REST applications is the use of standard HTTP verbs and error codes in the pursuit or removing unnecessary variation among different services.

Another key feature of REST applications is the use of HATEOAS or Hypermedia As The Engine of Application State. This provides REST applications a self-documenting nature making it easier for developers to interact with a REST service without a priori knowledge.

Secure REST services must only provide HTTPS endpoints. This protects authentication credentials in transit, for example passwords, API keys or JSON Web Tokens. It also allows clients to authenticate the service and guarantees integrity of the transmitted data.

See the Transport Layer Protection Cheat Sheet for additional information.

Consider the use of mutually authenticated client-side certificates to provide additional protection for highly privileged web services.

Non-public REST services must perform access control at each API endpoint. Web services in monolithic applications implement this by means of user authentication, authorisation logic and session management. This has several drawbacks for modern architectures which compose multiple micro services following the RESTful style.

  • in order to minimise latency and reduce coupling between services, the access control decision should be taken locally by REST endpoints
  • user authentication should be centralised in a Identity Provider (IdP), which issues access tokens

There seems to be a convergence towards using JSON Web Tokens (JWT) as the format for security tokens. JWTs are JSON data structures containing a set of claims that can be used for access control decisions. A cryptographic signature or message authentication code (MAC) can be used to protect the integrity of the JWT.

  • Ensure JWTs are integrity protected by either a signature or a MAC. Do not allow the unsecured JWTs: {'alg':'none'}.
    • See here
  • In general, signatures should be preferred over MACs for integrity protection of JWTs.

If MACs are used for integrity protection, every service that is able to validate JWTs can also create new JWTs using the same key. This means that all services using the same key have to mutually trust each other. Another consequence of this is that a compromise of any service also compromises all other services sharing the same key. See here for additional information.

The relying party or token consumer validates a JWT by verifying its integrity and claims contained.

  • A relying party must verify the integrity of the JWT based on its own configuration or hard-coded logic. It must not rely on the information of the JWT header to select the verification algorithm. See here and here

Some claims have been standardised and should be present in JWT used for access controls. At least the following of the standard claims should be verified:

  • iss or issuer - is this a trusted issuer? Is it the expected owner of the signing key?
  • aud or audience - is the relying party in the target audience for this JWT?
  • exp or expiration time - is the current time before the end of the validity period of this token?
  • nbf or not before time - is the current time after the start of the validity period of this token?

Public REST services without access control run the risk of being farmed leading to excessive bills for bandwidth or compute cycles. API keys can be used to mitigate this risk. They are also often used by organisation to monetize APIs; instead of blocking high-frequency calls, clients are given access in accordance to a purchased access plan.

API keys can reduce the impact of denial-of-service attacks. However, when they are issued to third-party clients, they are relatively easy to compromise.

  • Require API keys for every request to the protected endpoint.
  • Return 429 Too Many Requests HTTP response code if requests are coming in too quickly.
  • Revoke the API key if the client violates the usage agreement.
  • Do not rely exclusively on API keys to protect sensitive, critical or high-value resources.
  • Apply a whitelist of permitted HTTP Methods e.g. GET, POST, PUT.
  • Reject all requests not matching the whitelist with HTTP response code 405 Method not allowed.
  • Make sure the caller is authorised to use the incoming HTTP method on the resource collection, action, and record

In Java EE in particular, this can be difficult to implement properly. See Bypassing Web Authentication and Authorization with HTTP Verb Tampering for an explanation of this common misconfiguration.

  • Do not trust input parameters/objects.
  • Validate input: length / range / format and type.
  • Achieve an implicit input validation by using strong types like numbers, booleans, dates, times or fixed data ranges in API parameters.
  • Constrain string inputs with regexps.
  • Reject unexpected/illegal content.
  • Make use of validation/sanitation libraries or frameworks in your specific language.
  • Define an appropriate request size limit and reject requests exceeding the limit with HTTP response status 413 Request Entity Too Large.
  • Consider logging input validation failures. Assume that someone who is performing hundreds of failed input validations per second is up to no good.
  • Have a look at input validation cheat sheet for comprehensive explanation.
  • Use a secure parser for parsing the incoming messages. If you are using XML, make sure to use a parser that is not vulnerable to XXE_Processing) and similar attacks.

A REST request or response body should match the intended content type in the header. Otherwise this could cause misinterpretation at the consumer/producer side and lead to code injection/execution.

  • Document all supported content types in your API.

Validate request content types

  • Reject requests containing unexpected or missing content type headers with HTTP response status 406 Unacceptable or 415 Unsupported Media Type.
  • For XML content types ensure appropriate XML parser hardening, see the XXE cheat sheet.
  • Avoid accidentally exposing unintended content types by explicitly defining content types e.g. Jersey (Java) @consumes('application/json'); @produces('application/json'). This avoids XXE-attack_Processing) vectors for example.

Send safe response content types

Xxe Cheat Sheet Github Free

Xxe Cheat Sheet Github

It is common for REST services to allow multiple response types (e.g. application/xml or application/json, and the client specifies the preferred order of response types by the Accept header in the request.

  • Do NOT simply copy the Accept header to the Content-type header of the response.
  • Reject the request (ideally with a 406 Not Acceptable response) if the Accept header does not specifically contain one of the allowable types.

Services including script code (e.g. JavaScript) in their responses must be especially careful to defend against header injection attack.

  • Ensure sending intended content type headers in your response matching your body content e.g. application/json and not application/javascript.
  • Avoid exposing management endpoints via Internet.
  • If management endpoints must be accessible via the Internet, make sure that users must use a strong authentication mechanism, e.g. multi-factor.
  • Expose management endpoints via different HTTP ports or hosts preferably on a different NIC and restricted subnet.
  • Restrict access to these endpoints by firewall rules or use of access control lists.
  • Respond with generic error messages - avoid revealing details of the failure unnecessarily.
  • Do not pass technical details (e.g. call stacks or other internal hints) to the client.
  • Write audit logs before and after security related events.
  • Consider logging token validation errors in order to detect attacks.
  • Take care of log injection attacks by sanitising log data beforehand.

To make sure the content of a given resources is interpreted correctly by the browser, the server should always send the Content-Type header with the correct content type, and preferably the Content-Type header should include a charset. The server should also send the X-Content-Type-Options: nosniffsecurity header to make sure the browser does not try to detect a different Content-Type than what is actually sent (can lead to XSS).

Additionally the client should send the X-Frame-Options: denysecurity header to protect against drag'n drop clickjacking attacks in older browsers.

Cross-Origin Resource Sharing (CORS) is a W3C standard to flexibly specify what cross-domain requests are permitted. By delivering appropriate CORS Headers your REST API signals to the browser which domains, AKA origins, are allowed to make JavaScript calls to the REST service.

  • Disable CORS headers if cross-domain calls are not supported/expected.
  • Be as specific as possible and as general as necessary when setting the origins of cross-domain calls.

RESTful web services should be careful to prevent leaking credentials. Passwords, security tokens, and API keys should not appear in the URL, as this can be captured in web server logs, which makes them intrinsically valuable.

  • In POST/PUT requests sensitive data should be transferred in the request body or request headers.
  • In GET requests sensitive data should be transferred in an HTTP Header.

OK:

https://example.com/resourceCollection/[ID]/action

https://twitter.com/vanderaj/lists

NOT OK:

https://example.com/controller/123/action?apiKey=a53f435643de32 because API Key is into the URL.

HTTP defines status code. When designing REST API, don't just use 200 for success or 404 for error. Always use the semantically appropriate status code for the response.

Here is a non-exhaustive selection of security related REST API status codes. Use it to ensure you return the correct code.

CodeMessageDecription
200OKResponse to a successful REST API action. The HTTP method can be GET, POST, PUT, PATCH or DELETE.
201CreatedThe request has been fulfilled and resource created. A URI for the created resource is returned in the Location header.
202AcceptedThe request has been accepted for processing, but processing is not yet complete.
301Moved PermanentlyPermanent redirection.
304Not ModifiedCaching related response that returned when the client has the same copy of the resource as the server.
307Temporary RedirectTemporary redirection of resource.
400Bad RequestThe request is malformed, such as message body format error.
401UnauthorizedWrong or no authentication ID/password provided.
403ForbiddenIt's used when the authentication succeeded but authenticated user doesn't have permission to the request resource.
404Not FoundWhen a non-existent resource is requested.
405Method Not AcceptableThe error for an unexpected HTTP method. For example, the REST API is expecting HTTP GET, but HTTP PUT is used.
406UnacceptableThe client presented a content type in the Accept header which is not supported by the server API.
413Payload too largeUse it to signal that the request size exceeded the given limit e.g. regarding file uploads.
415Unsupported Media TypeThe requested content type is not supported by the REST service.
429Too Many RequestsThe error is used when there may be DOS attack detected or the request is rejected due to rate limiting.
500Internal Server ErrorAn unexpected condition prevented the server from fulfilling the request. Be aware that the response should not reveal internal information that helps an attacker, e.g. detailed error messages or stack traces.
501Not ImplementedThe REST service does not implement the requested operation yet.
503Service UnavailableThe REST service is temporarily unable to process the request. Used to inform the client it should retry at a later time.

Overwatch download mac free. Additional information about HTTP return code usage in REST API can be found here and here.

Erlend Oftedal - erlend.oftedal@owasp.org

Andrew van der Stock - vanderaj@owasp.org

Tony Hsu Hsiang Chih- Hsiang_chihi@yahoo.com

Johan Peeters - yo@johanpeeters.com

Jan Wolff - jan.wolff@owasp.org

Rocco Gränitz - rocco.graenitz@owasp.org

Manh Pham - manhpt2811@gmail.com

Intro:

I was interested in hacking and security from the age of 15, that's almost 20 years now. And always learned new things that interested me. One period I learn more about hardware, Raspberry and Arduino and another about buffer overflow exploitation. Next periods I learn a new programming language, and then more about web security. Because Hacking is such a broad field I never felt like a hacker. In my eyes, a hacker was always somebody that could write exploit code, spot a vulnerability from miles away and do all this in the command line.
So my journey continued. I got the CEH certificate, learned some more but still, I won't call myself a hacker.
Now I'm at a point in my career where I want to invest more time actively practicing what I've learned over the years. And this brought me to bug bounty programs. I am a member of 2 for a couple of years, but never really searched for bugs, as it was a bit overwhelming at first.
Now I feel confident and going to participate in the community and the programs.

This post is a checklist mainly for me to test a target. In my mind, there is so much to test, and if you're new to bug hunting, you easily forget something that could lead to a bounty. Bug hunting is competitive, but yet a nice community that likes to share, and I want to be part of that.

Xxe Cheat Sheet Github 2

Scope Types:

Depending on the target you get different scope types. This will also determine what tools you will need.

*.domain.comFull-domain scope
sub.domain.comSub-domain scope
Ip AddressSingle-address scope
ApplicationApplication scope

Reconnaissance:

Believe it or not, it all starts here. I have read so much content on the internet, watched video's, did CTF's and it all comes down to good and thorough reconnaissance. If you go in blind you certainly missed something. Everywhere I read it is the same, 85% is recon, the rest just using what you discovered.
First of all, document your findings and take screenshots. Organize them and take notes of everything you discover.

Passive:

First, we do passive recon to see what we can find on the internet. Here is a list of resources for this:

Resource LinkDescriptionScope Type
https://www.shodan.io/See if there are entries in the Shodan database.Full-domain
https://crt.sh/Check for certificate information.Full-domain, Sub-domain
https://dnsdumpster.com/Look for DNS entriesFull-domain, Sub-domain
http://dnsgoodies.com/Collection of DNS toolsFull-domain, Sub-domain
http://www.visualsitemapper.comVisual map a website.Sub-domain
https://web.archive.org/See if there are older versions of the site.Sub-domain
https://github.com/michenriksen/gitrobScanning GitHub commits history of user or company.Full-domain, Sub-domain
https://github.com/dxa4481/truffleHogSame as above, a GitHub crawler.Full-domain, Sub-domain

Xxe Cheat Sheet Github Full

Active:

Now that we have the basics, we can proceed to actually do requests to the site ourselves. Here we will scan the information we found with the passive recon more in-depth.

https://github.com/1N3/Sn1perA full automated recon and testing tool.Full-domain, Sub-domain
https://bitbucket.org/LaNMaSteR53/recon-ngWeb Reconnaissance framework is written in PythonFull-domain, Sub-domain
https://github.com/michenriksen/aquatoneAnother web recon tool.Full-domain, Sub-domain
https://github.com/aboul3la/Sublist3rScan for subdomains.Full-domain
https://github.com/jobertabma/virtual-host-discoveryFinding VHOSTS.Full-domain, Sub-domain
https://github.com/sandrogauci/wafw00fSee if there are protections in place.Full-domain, Sub-domain
https://www.owasp.org/index.php/Category:OWASP_DirBuster_ProjectBrute forcing of web directories.Full-domain, Sub-domain
https://github.com/jobertabma/relative-url-extractorGet paths from JS files.Full-domain, Sub-domain
https://xsser.03c8.net/Cross-site scripting scanner.Full-domain, Sub-domain

After all these findings don't forget to do a simple portscan on the hosts you discovered, and don't just scan for regular ports.
What I sometimes struggled with was finding good wordlists. Here I discovered a project that collected and structured all sorts of lists.
https://github.com/danielmiessler/SecLists

Structured Documentation:

Now that you have all this information it's important to structure and sort it out a bit. Some of these tools will get duplicates, and one tool will find more than the other. So filtering this information will benefit you later.

Techniques to test:

This will be the description mainly for myself so I don't forget to test anything.
When you got all your recon done and got the endpoints, we can start testing for vulnerabilities. Let's Go.

XSS ( Cross-Site scripting ):

One of the most common bugs in a web-application are Cross-site scripting bugs. These bugs are usually quickly discovered by researches.

Type 0DOM Based XSSXSS where the entire tainted data flow from source to sink takes place in the browser
Type 1Stored or Persistent XSSOccurs when user input is stored on the target server. And then a victim is able to retrieve the stored data from the web application without that data being made safe.
Type 2Reflected or Non-Persistent XSSOccurs when user input is immediately returned by a web application, without that data being made safe.

Tools to use when searching for XSS:

xsserhttps://xsser.03c8.net/
owasp zaphttps://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project
XSStrikehttps://github.com/s0md3v/XSStrike

When writing a PoC the best practice is always use alert(document.domain) instead of alert(1). This way you are shute that it comes from the correct domain and it will be a valid XSS bug.
Here I have 2 lists of XSS payloads you can use.
XSS-sorted
XSS-unsorted
Also here the link to the OWASP XSS cheat sheet:
https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet

Open Redirects:

Unvalidated redirects could redirect the user to an unwanted URL
ex. http://example.com/example.php?url=http://malicious.example.com
Look for the following parameters in the url, source and javascript code:

  • url
  • returnurl
  • redirect
  • getParameters

Als last the OWASP open redirect cheat sheet:
https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md

Xxe Cheat Sheet Github Download

XXE (XML External Entity):

I find this an intresting attack vector, the idea of manipulating an xml supported document or data to exploit your target amazes me.
So what is XXE:
if XML userinput is not correctly sanitized, an attacker can manipulate the data or files to read local server files or get remote code execution.

Where can we find these bugs:

  • fileuploads xlsx, svg, doxs, xml ..
  • POST or GET data that uses JSON or XML parsing.

How do we test for these bugs:

  • do curl requests ( curl -d @xml.txt http://example.com/login.php )
  • Look for out of band xxe ( when you do not get a responce but the server processes the data.

Some examples:

Tools for automating:

  • XXEinjector