gophish/models
Jordan Wright e3352f481e
Implement SSRF Mitigations (#1940)
Initial commit of SSRF mitigations.

This fixes #1908 by creating a *net.Dialer which restricts outbound connections to only allowed IP ranges. This implementation is based on the blog post at https://www.agwa.name/blog/post/preventing_server_side_request_forgery_in_golang

To keep things backwards compatible, by default we'll only block connections to 169.254.169.254, the link-local IP address commonly used in cloud environments to retrieve metadata about the running instance. For other internal addresses (e.g. localhost or RFC 1918 addresses), it's assumed that those are available to Gophish.

To support more secure environments, we introduce the `allowed_internal_hosts` configuration option where an admin can set one or more IP ranges in CIDR format. If addresses are specified here, then all internal connections will be blocked except to these hosts.

There are various bits about this approach I don't really like. For example, since various packages all need this functionality, I had to make the RestrictedDialer a global singleton rather than a dependency off of, say, the admin server. Additionally, since webhooks are implemented via a singleton, I had to introduce a new function, `SetTransport`.

Finally, I had to make an update in the gomail package to support a custom net.Dialer.
2020-08-20 09:36:18 -05:00
..
attachment.go Added documentation for multiple endpoints. Fixes #54 2016-01-24 20:47:16 -06:00
campaign.go General code cleanup as part of an effort to integrate staticcheck into our CI pipeline. 2020-05-25 21:46:36 -05:00
campaign_test.go Improve the Performance of Sending Emails (#1753) 2020-02-29 20:19:54 -06:00
doc.go Major refactoring - created auth, config, models, controllers, and middleware packages. Should help provide modularity and a clean architecture. 2014-01-09 00:42:05 -06:00
email_request.go General code cleanup as part of an effort to integrate staticcheck into our CI pipeline. 2020-05-25 21:46:36 -05:00
email_request_test.go Refactor servers (#1321) 2018-12-15 15:42:32 -06:00
group.go General code cleanup as part of an effort to integrate staticcheck into our CI pipeline. 2020-05-25 21:46:36 -05:00
group_test.go Performance Improvements for Campaign and Group Creation (#1686) 2019-12-02 23:00:11 -06:00
imap.go Added support to allow invalid IMAP certificates (#1909) 2020-08-08 15:03:42 -05:00
maillog.go General code cleanup as part of an effort to integrate staticcheck into our CI pipeline. 2020-05-25 21:46:36 -05:00
maillog_test.go Improve the Performance of Sending Emails (#1753) 2020-02-29 20:19:54 -06:00
models.go Add ability to provide initial API key on service standup (#1883) 2020-07-01 22:06:31 -05:00
models_test.go Performance Improvements for Campaign and Group Creation (#1686) 2019-12-02 23:00:11 -06:00
page.go General code cleanup as part of an effort to integrate staticcheck into our CI pipeline. 2020-05-25 21:46:36 -05:00
page_test.go Support Re-enabling CapturePasswords for Landing Pages (#1271) 2018-11-11 12:34:26 -06:00
rbac.go Implement User Management API (#1473) 2019-05-31 13:58:18 -05:00
rbac_test.go Initial commit of RBAC support. (#1366) 2019-02-19 20:33:50 -06:00
result.go Improve the Performance of Sending Emails (#1753) 2020-02-29 20:19:54 -06:00
result_test.go Performance Improvements for Campaign and Group Creation (#1686) 2019-12-02 23:00:11 -06:00
smtp.go Implement SSRF Mitigations (#1940) 2020-08-20 09:36:18 -05:00
smtp_test.go Implement SSRF Mitigations (#1940) 2020-08-20 09:36:18 -05:00
template.go Fixed various minor linting issues 2018-12-15 21:38:51 -06:00
template_context.go Minor cleanup on webhook feature integration 2019-12-15 22:07:55 -06:00
template_context_test.go Add {{.BaseURL}} template tag to provide the root URL for static files. Fixes #1182 2018-09-03 20:28:32 -05:00
user.go Initial Implementation of a Password Policy (#1867) 2020-06-19 22:03:51 -05:00
user_test.go General code cleanup as part of an effort to integrate staticcheck into our CI pipeline. 2020-05-25 21:46:36 -05:00
webhook.go Add Webhook Support 2019-12-15 20:27:21 -06:00