Added X-Frame-Options: SAMEORIGIN to HTTP response header to prevent clkickjacking
This commit is contained in:
1 parent
f8b01e7b38
commit
d9637b4424
2 files changed
+15
No files matched your search
@@ -7349,6 +7349,7 @@ void redirect(LOGBOOK *lbs, const char *rel_path) {
|
||||
/* redirect */
|
||||
rsprintf("HTTP/1.1 302 Found\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
if (keep_alive) {
|
||||
rsprintf("Connection: Keep-Alive\r\n");
|
||||
rsprintf("Keep-Alive: timeout=60, max=10\r\n");
|
||||
@@ -7596,6 +7597,7 @@ void show_http_header(LOGBOOK *lbs, BOOL expires, const char *cookie, int code)
|
||||
rsprintf("HTTP/1.1 200 Document follows\r\n");
|
||||
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
|
||||
if (getcfg("global", "charset", str, sizeof(str)))
|
||||
rsprintf("Content-Type: text/html;charset=%s\r\n", str);
|
||||
@@ -7622,6 +7624,7 @@ void show_plain_header(int size, const char *file_name) {
|
||||
/* header */
|
||||
rsprintf("HTTP/1.1 200 Document follows\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
rsprintf("Accept-Ranges: bytes\r\n");
|
||||
|
||||
if (keep_alive) {
|
||||
@@ -8390,6 +8393,7 @@ void show_error(const char *error) {
|
||||
/* header */
|
||||
rsprintf("HTTP/1.1 404 Not Found\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
if (getcfg("global", "charset", str, sizeof(str)))
|
||||
rsprintf("Content-Type: text/html;charset=%s\r\n", str);
|
||||
else
|
||||
@@ -8456,6 +8460,7 @@ void set_sid_cookie(LOGBOOK *lbs, const char *sid, const char *full_name) {
|
||||
|
||||
rsprintf("HTTP/1.1 302 Found\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
if (keep_alive) {
|
||||
rsprintf("Connection: Keep-Alive\r\n");
|
||||
rsprintf("Keep-Alive: timeout=60, max=10\r\n");
|
||||
@@ -8520,6 +8525,7 @@ void send_file_direct(char *file_name, bool allow_html) {
|
||||
|
||||
rsprintf("HTTP/1.1 200 Document follows\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
rsprintf("Accept-Ranges: bytes\r\n");
|
||||
|
||||
/* set expiration time to one day if no thumbnail */
|
||||
@@ -15774,6 +15780,7 @@ int show_md5_page(LOGBOOK *lbs) {
|
||||
/* header */
|
||||
rsprintf("HTTP/1.1 200 Document follows\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
rsprintf("Accept-Ranges: bytes\r\n");
|
||||
rsprintf("Connection: close\r\n");
|
||||
rsprintf("Content-Type: text/plain;charset=%s\r\n", DEFAULT_HTTP_CHARSET);
|
||||
@@ -19849,6 +19856,7 @@ void show_rss_feed(LOGBOOK *lbs) {
|
||||
|
||||
rsprintf("HTTP/1.1 200 Document follows\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
|
||||
if (!getcfg("global", "charset", charset, sizeof(charset)))
|
||||
strcpy(charset, DEFAULT_HTTP_CHARSET);
|
||||
@@ -27275,6 +27283,7 @@ void show_uploader_json(LOGBOOK *lbs) {
|
||||
|
||||
rsprintf("HTTP/1.1 200 Document follows\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
rsprintf("Accept-Ranges: bytes\r\n");
|
||||
rsprintf("Pragma: no-cache\r\n");
|
||||
rsprintf("Cache-control: private, max-age=0, no-cache, no-store\r\n");
|
||||
@@ -30376,6 +30385,7 @@ void server_loop(void) {
|
||||
/* just return header */
|
||||
rsprintf("HTTP/1.1 200 OK\r\n");
|
||||
rsprintf("Server: ELOG HTTP %s-%s\r\n", VERSION, git_revision());
|
||||
rsprintf("X-Frame-Options: SAMEORIGIN\r\n");
|
||||
rsprintf("Connection: close\r\n");
|
||||
rsprintf("Content-Type: text/html\r\n\r\n");
|
||||
keep_alive = FALSE;
|
||||
|
||||
@@ -90,6 +90,8 @@ Hosts deny = 127.0.0.1
|
||||
body, headers["Content-Type"] = multipart(fields, files)
|
||||
connection.request(method, path, body, headers)
|
||||
response = connection.getresponse()
|
||||
if response.headers.get_all("X-Frame-Options") != ["SAMEORIGIN"]:
|
||||
raise AssertionError(f"missing or duplicate clickjacking header on {method} {path}")
|
||||
response_headers = dict(response.getheaders())
|
||||
response_headers['Set-Cookie'] = '\n'.join(response.headers.get_all('Set-Cookie', []))
|
||||
result = response.status, response_headers, response.read().decode(errors="replace")
|
||||
@@ -124,6 +126,9 @@ Hosts deny = 127.0.0.1
|
||||
time.sleep(.1)
|
||||
else:
|
||||
raise RuntimeError('daemon did not start')
|
||||
check(request('/public/')[0] == 200, 'public page includes clickjacking header')
|
||||
check(request('/missing/')[0] == 404, 'error page includes clickjacking header')
|
||||
check(request('/public/elog.css')[0] == 200, 'static file includes clickjacking header')
|
||||
check(request('/protected/')[0] == 200, 'login page available')
|
||||
status, headers, body = request('/protected/', [('uname', 'admin'), ('upassword', 'test-password')])
|
||||
match = re.search(r'sid=([0-9a-f]{30})', headers.get('Set-Cookie', ''))
|
||||
|
||||
Reference in new issue
Block a user