Debian Codegraph @

doc/src/guide/security_model.asciidoc

raw
1 [[security_model]]
2 == Security model
3
4 Cowboy's security model is based on the principle that the server
5 delegates security responsibilities to the underlying Erlang/OTP
6 platform, the operating system and to the application code.
7
8 Cowboy and its main dependency Cowlib perform input validation and
9 parsing according to the relevant protocol specifications. Cowlib's
10 parsers are strict: invalid input typically results in a crash that
11 Cowboy turns into a 4xx error response (for example a 400 Bad Request).
12 Cowboy also provides numerous options to limit resource usage (timeouts,
13 buffer sizes, header lengths, concurrent streams and so on) in order
14 to mitigate denial of service attacks. These limits must be configured
15 appropriately by the application.
16
17 Output construction for protocol elements (status lines, headers,
18 bodies in some cases) is performed by Cowlib, which is lax when
19 building data: it will output largely what it is given, without
20 performing validation or sanitization. Cowboy itself performs only
21 limited sanitization in some cases. For example when using the
22 HTTP/1.1 or HTTP/2 protocol it will reject response header values containing
23 CRLF characters by default (via the `invalid_response_headers` option
24 set to `error_terminate`). It is the responsibility of the application
25 (and by extension Cowboy when it calls into Cowlib) to sanitize any
26 data provided for use in responses. Response data must be valid
27 according to the relevant specifications.
28
29 Cowboy trusts the code it runs: handlers, middleware, stream
30 handlers, router constraints and any other modules provided by the
31 application. Any security decision (authentication, authorization,
32 access control and so on) must be performed by this code. Cowboy does
33 not implement any such mechanisms itself.
34
35 All code runs with the privileges of the Erlang virtual machine.