Skip to content

Fix memory bugs in the GTK login, warn when gst-plugins-good is missing - #498

Open
leifrossau wants to merge 1 commit into
jstaf:masterfrom
leifrossau:pr/gtk-login-fixes
Open

leifrossau wants to merge 1 commit into
jstaf:masterfrom
leifrossau:pr/gtk-login-fixes

Conversation

@leifrossau

Copy link
Copy Markdown

Problem

  • uri_get_host mallocs len bytes and then writes host[len] (heap overflow by one byte).
  • The TLS error handler passes a possibly-NULL host to strncmp and never frees it.
  • The default case of the TLS error switch snprintf()s into an uninitialized char *reason.
  • Without GStreamer's autoaudiosink element (package gst-plugins-good), WebKitGTK's web process breaks while loading the Microsoft login page, and the Microsoft Authenticator number-matching code never appears, so the login looks like it hangs. I hit this on Arch; installing gst-plugins-good fixed it.
  • A login window closed without completing failed later with an obscure token error.

Fix

  • Fix the three memory bugs.
  • Warn before opening the login window if autoaudiosink is missing (checked with gst-inspect-1.0 --exists, skipped silently if that tool isn't installed), and depend on the plugins in the packages: gstreamer1-plugins-good (rpm), gstreamer1.0-plugins-good (deb).
  • Say "Login did not complete" and point at onedriver -n when no code was returned.

Testing

Extra unit test for uri_get_host edge cases. The login flow was tested manually only. go build ./... and go vet ./... pass.

Notes

The Arch PKGBUILD isn't in this repo; it would need gst-plugins-good too.

🤖 Generated with Claude Code

oauth2_gtk.c:
- uri_get_host() allocated len bytes and then wrote host[len], a one byte
  heap overflow. Allocate len+1 and use memcpy; use size_t for the offsets.
- web_view_load_failed_tls() passed a possibly NULL host to strncmp() and never
  freed it.
- the default case of the TLS error switch snprintf()ed into the
  uninitialized pointer 'reason'. Use a stack buffer.

Without gst-plugins-good (GStreamer's autoaudiosink), WebKitGTK's web process
breaks while loading the Microsoft login page and the number to enter in the
Microsoft Authenticator app is never shown, which looks like a hanging login.
Log a warning before opening the login window if autoaudiosink is missing, and
depend on gst-plugins-good in the deb and rpm packages.

Also, when the login window is closed or no code was returned, say so and
point to 'onedriver -n' (log in using the normal web browser) instead of
failing later with an obscure token endpoint error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant