🔒 Glitch unofficial oAuth

Hi everyone!
Today I’ve built a simple app that lets you sign in to any website with Glitch.

You only need to send your users to the auth screen, indicating the callback as a URI parameter.

When the user signs in, the website redirects the user to your endpoint with the URI parameter “token” which contains the user information as a JSON string.

The information is encoded using a cipher, so you need to decode it using our decryptor script.

:point_right: Check it out: https://oauth-login.glitch.me/

No rickrolls this time, you have my word

Happy Glitching!
Tiago

PS: Inspired by Can we have Glitch oAuth

What’s your opinion?
  • Cool
  • This is useless

0 voters

2 Likes

this seems to operate on the honor system, but I’ve only looked briefly at the code. would you be willing to post an explanation of how this works?

1 Like

Honor system?

Of course! Basicaly you input your username and it generates a random code. Then, when you click verify, it fetches Glitch’s open API and looks at your profile description. If the description contains the code, the project jumps over the lazy dog and redirects the user to your website.

1 Like

well an honorable user would follow the rules of not redirecting if they aren’t the right user. does it have a way to enforce those rules on dishonorable users? could they redirect anyway? in my understanding they can

1 Like

Sorry, I’m getting more and more confused…

could an attacker forge an encrypted token to make them look like a different victim user? from what I’ve seen of the code, I’m getting a sense that yes, they can in a reasonable threat model, where the attacker has their own computer.

3 Likes

Well… Yes, an attacker could, but there’s a catch:
I actually didn’t explain, but like you probably aren’t going to but big secrets on top of this auth: This is just a way of knowing that probably (because of the problem you said) the user has the glitch account ________ and some information about the account.
If you want to use something that actually works, then check out AuthFlow: you can use Google’s built-in token verification system and make sure the user is real.

So you’ve put a nice GUI onto this:

1 Like

Well, I was inspired by that, but actually didn’t even look at it’s code! :rofl:

GlitchOAuth I think checks the login code on its server, which makes it possible to verify a login without trusting any client, which is much stronger if you’re building a full stack app.

1 Like

Yeah but there’s the problem of keeping the website static

Hi, I really think this is a good idea, but I really think you should make a few changes. As @wh0 said

Assuming he meant that the user is trusted not to go messing with the code, then yeah, I agree

var username = "tiagorangel";
var redirect = "https://example.com";

if (typeof crypt !== "function") {
  var crypt = (p, t) => {
    t = "oauth";
    let r = (t) => t.split("").map((t) => t.charCodeAt(0)),
      a = (t) => ("0" + Number(t).toString(16)).substr(-2),
      e = (p) => r(t).reduce((t, p) => t ^ p, p);
    return p.split("").map(r).map(e).map(a).join("");
  };
}

fetch(`https://api.glitch.com/v1/users/by/login?login=${username}`)
  .then((res) => res.json())
  .then((response) => {
    var token = crypt(JSON.stringify(response));
    window.location.replace(
      `${redirect}?token=${token}&login_provider=oauth-login&provider_url=example.com`
    );
  });

})

This code could be injected at the login screen, bypassing any means of authentication.
Maybe you could move the actual login/verification to a backend server and give the client a token to interact with the backend with, sort of like pocketbase and its JavaScript library. Basically what the library does is:

  1. It submits the credentials to the server
  2. The server gives a token and the client stores it in localStorage
  3. The library interacts with the client using that token

Although, the way your project works, step one would probably be setting a login token in the description.

Ooops, it seems like there are a lot of security problems here!
The big problem is keeping the site static and 24/7 awake, because I don’t want users to keep looking at the loading screen for 3 hours :rofl:
I am currently working to improve the security of this, anyway thanks!


EDIT: Implemented IIFE, minified javascript, and obfuscated some code (sorry glitch, please don’t report my project!).

Obfuscating code is not really a good way of implementing security. Instead, you should write safe code in the first place (irrespective of whether you ‘have to’ write the code in some way to keep it static).

5 Likes

Unfortunately…

I’d rather prioritize my user’s security over speed. For example, I make some sort of twitter clone where I authenticate users via Glitch. If a user’s login could easily be easily forged, then I could pretend to be that user. Also, I agree with EddiesTech as I used a deobfuscator which allowed me to grab a basic concept on how the code worked. Someone really malicious could do the same thing.

2 Likes

I Glitched The Auth Site By Having It Redirect To The Auth Site

This Also Sounds Good For My Game Pencil Agario

1 Like

Yes, that’s a security concern, but if you want something secure, check out AuthFlow