# Does specifying localhost as an allowable redirect present security problems?

**URL:** <https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603>\
**Category:** Questions\
**Created:** [November 3, 2020, 9:33pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603 "2020-11-03T21:33:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![universalhandle](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/universalhandle/32/2328_2.png) [@universalhandle](https://devforum.okta.com/u/universalhandle)\
**Post date:** [November 3, 2020, 9:33pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/1 "2020-11-03T21:33:12Z")

</div>

I’ve seen it [suggested](https://support.okta.com/help/s/article/The-redirect-uri-parameter-must-be-an-absolute-URI?language=en_US) in a few official Okta [docs](https://developer.okta.com/docs/guides/sign-into-web-app/aspnet/create-okta-application/) that developers should add [http://localhost](http://localhost):somePort to their login redirect URIs.

I haven’t thought this all the way through, but this smells funny to me. Suppose I work for the Acme Corporation, and I’ve set up my HR app with Okta. For the app’s dev environment, I’ve added [http://localhost:3434](http://localhost:3434) to my login redirect URIs config. Since any machine can call itself localhost, isn’t there some risk that a nefarious actor could masquerade behind the legitimacy of the Acme Corp logo and login screen? Even though the credentials themselves wouldn’t be compromised (because they only ever pass through Okta’s hands), couldn’t the Acme/Okta login give users a false sense of security about the authenticity of the site they are using, resulting in employees being fooled into providing sensitive information to an outsider?

If there are not security implications around the redirect URIs, why does the setting exist at all? Why not allow any site which has the Okta client ID to redirect?

Thanks for engaging in this thought experiment with me!

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [November 3, 2020, 9:37pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/2 "2020-11-03T21:37:23Z")

</div>

You should only use `localhost` when developing locally on your machine. For production, you should use a full domain with HTTPS. [This guide](https://developer.okta.com/docs/guides/deploy-your-app/overview/) specifies the things you’ll need for production.

---

<div class="post-metadata">

**Author:** ![universalhandle](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/universalhandle/32/2328_2.png) [@universalhandle](https://devforum.okta.com/u/universalhandle)\
**Post date:** [November 3, 2020, 9:59pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/3 "2020-11-03T21:59:59Z")

</div>

Thanks for your response,@mraible, but I’m really hoping to do a deep dive on what security issues such a configuration might raise.

Of course a production deployment of the Acme HR app would live at a FQDN like [https://hr.acme.corp](https://hr.acme.corp), but development never stops, does it? Developers will always have an instance going at [http://localhost:3434](http://localhost:3434). That means devs will either have to:

- Leave `localhost` in the redirect config, and authenticate with Okta even when accessing their local instance (annoying but not the worst thing, if there’s no added risk).
- Take `localhost` out of the redirect config to mitigate risk and add some mechanism (likely a feature flag) to their app to disable the Okta integration in some contexts.
- Some other option I’m not thinking of?

Most of the mentions of `localhost` that I’ve seen are in “quick start”-type docs. In that context, the configuration makes plenty of sense, but advice given in “quick start” documentation is often intentionally oversimplified and not suitable once an app has gone to production. It’s not clear to me whether the advice given around `localhost` falls into this category or not.

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [November 3, 2020, 10:13pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/4 "2020-11-03T22:13:27Z")

</div>

We recommend developers have their own Okta developer account when developing an app. I don’t think it’s a good idea to use your production org for development purposes.

Everyone should go through our [pre-launch checklist](https://developer.okta.com/docs/guides/production-deployment/deployment-checklist/) before going to production.

---

<div class="post-metadata">

**Author:** ![markusr](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@markusr](https://devforum.okta.com/u/markusr)\
**Post date:** [November 4, 2020, 10:08pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/5 "2020-11-04T22:08:50Z")

</div>

How’d you get localhost to work? I am getting a CORS issue (localhost:port has been added to trusted domains) SAML

---

<div class="post-metadata">

**Author:** ![universalhandle](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/universalhandle/32/2328_2.png) [@universalhandle](https://devforum.okta.com/u/universalhandle)\
**Post date:** [November 4, 2020, 11:31pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/6 "2020-11-04T23:31:59Z")

</div>

Your CORS issue sounds like an application issue rather than an Okta issue per se. Here’s a [good resource](https://enable-cors.org/) for most general “how do I enable CORS on platform X?” questions. There are also several Okta-specific examples in the [official documentation](https://developer.okta.com/docs/guides/protect-your-api/aspnet/configure-cors/) – select your tech from the “Instructions for” dropdown for information tailored to your use case.

---

<div class="post-metadata">

**Author:** ![universalhandle](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/universalhandle/32/2328_2.png) [@universalhandle](https://devforum.okta.com/u/universalhandle)\
**Post date:** [November 4, 2020, 11:39pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/7 "2020-11-04T23:39:48Z")

</div>

> [@mraible](#):
>
> I don’t think it’s a good idea to use your production org for development purposes.

Seems obvious now that you’ve said it. Thanks!

It does seem like poor practice to leave `localhost` in production config – and it might be a nice improvement to the pre-launch checklist to advise people to remove that – but using a separate org for development renders my “but, really, are there security implications?” question moot.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [November 5, 2020, 11:39pm UTC](https://devforum.okta.com/t/does-specifying-localhost-as-an-allowable-redirect-present-security-problems/11603/8 "2020-11-05T23:39:59Z")

</div>

Closed on November 5, 2020, 11:39pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
