Title: Account for hosts with/without ports in origin check · Issue #6166 · coder/code-server · GitHub
Open Graph Title: Account for hosts with/without ports in origin check · Issue #6166 · coder/code-server
X Title: Account for hosts with/without ports in origin check · Issue #6166 · coder/code-server
Description: Is there an existing issue for this? I have searched the existing issues OS/Web Information N/A Steps to Reproduce You can simulate with this NGINX config: proxy_set_header X-Forwarded-Host $host:$server_port; Expected If your origin is ...
Open Graph Description: Is there an existing issue for this? I have searched the existing issues OS/Web Information N/A Steps to Reproduce You can simulate with this NGINX config: proxy_set_header X-Forwarded-Host $host:$...
X Description: Is there an existing issue for this? I have searched the existing issues OS/Web Information N/A Steps to Reproduce You can simulate with this NGINX config: proxy_set_header X-Forwarded-Host $host:$...
Opengraph URL: https://github.com/coder/code-server/issues/6166
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Account for hosts with/without ports in origin check","articleBody":"### Is there an existing issue for this?\r\n\r\n- [X] I have searched the existing issues\r\n\r\n### OS/Web Information\r\n\r\nN/A\r\n\r\n### Steps to Reproduce\r\n\r\nYou can simulate with this NGINX config:\r\n\r\n```\r\nproxy_set_header X-Forwarded-Host $host:$server_port;\r\n```\r\n\r\n### Expected\r\n\r\nIf your origin is `https://domain.tld` and your host is `domain.tld:443` the check should pass. Same for `http://domain.tld` and `domain.tld:80`.\r\n\r\nAlso I think NGINX's `$host` actually does not include ports so it will fail if your config only has `$host` and if you host on a port other than 443 and 80 since you would get an origin like `https://domain.tld:8080` and the host would be `domain.tld`.\r\n\r\nTo fix the first we could just check the protocol on the origin and then add/remove 443 or 80.\r\n\r\nFor the second we could ignore the port altogether since I think the vulnerability does not happen across ports...\r\n\r\nBut I am not sure we should do anything; maybe the correct course of action is to edit the proxy config so the host and origin headers match. I have looked at other software but they all seem to do exact matches without messing around with the port. We could just edit the documentation to use `$http_host`.\r\n\r\n### Actual\r\n\r\nThe origin and domain are matched exactly so they do not match. Ends up causing the web sockets to fail with 1006.\r\n\r\n### Logs\r\n\r\n_No response_\r\n\r\n### Screenshot/Video\r\n\r\n_No response_\r\n\r\n### Does this issue happen in VS Code or GitHub Codespaces?\r\n\r\n- [X] I cannot reproduce this in VS Code.\r\n- [X] I cannot reproduce this in GitHub Codespaces.\r\n\r\n### Are you accessing code-server over HTTPS?\r\n\r\n- [X] I am using HTTPS.\r\n\r\n### Notes\r\n\r\nhttps://github.com/coder/code-server/issues/6161\r\n\r\nMight be causing issues reported in https://github.com/coder/code-server/issues/6023 and https://github.com/coder/code-server/issues/6064 as well.\r\n\r\nAnd possibly https://github.com/coder/code-server/issues/6014","author":{"url":"https://github.com/code-asher","@type":"Person","name":"code-asher"},"datePublished":"2023-04-24T18:58:48Z","url":"https://github.com/coder/code-server/issues/6166"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3462df05-c536-61f5-daa8-0274fe66b654 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95EE:3F3939:D11BF6:124F891:6B043DFA |
| html-safe-nonce | 87ccc9f4bbbc36c2936302a8f1750cb0efc75550a46c7fb3fa1ba1efbc18a6be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUVFOjNGMzkzOTpEMTFCRjY6MTI0Rjg5MTo2QjA0M0RGQSIsInZpc2l0b3JfaWQiOiIzMTMyMTUwMDc2ODY5NDU5NDUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1831b4565e5a9018900b28967b3ac03ee9bb02a963f4b8cf569311aa296121d3 |
| hovercard-subject-tag | issue:1681848013 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/code-server/6166/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f2a41c59d9452cf2eb13b8aaa2c295603f0814431977d5c7de97225939b59dcf/coder/code-server/issues/6166 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f2a41c59d9452cf2eb13b8aaa2c295603f0814431977d5c7de97225939b59dcf/coder/code-server/issues/6166 |
| og:image:alt | Is there an existing issue for this? I have searched the existing issues OS/Web Information N/A Steps to Reproduce You can simulate with this NGINX config: proxy_set_header X-Forwarded-Host $host:$... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | code-asher |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/code-server git https://github.com/coder/code-server.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 172953845 |
| octolytics-dimension-repository_nwo | coder/code-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172953845 |
| octolytics-dimension-repository_network_root_nwo | coder/code-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width