security: escape API values before rendering, add a security policy - #18
Merged
Conversation
The table renders repositories belonging to whichever account you point the page at, and every value went straight into an innerHTML template. There was no escaping function in the file at all. Nothing displayed today can carry markup: GitHub constrains repository names to A-Za-z0-9._-, and languages and SPDX identifiers come from fixed lists. So this is not an exploitable hole, and calling it one would be overstating it. It is still worth closing. The constraint that makes those fields safe belongs to GitHub, not to this page, and it covers exactly the fields shown now. Adding a repository description or a topic list, both free text, would create an injection point with nothing in the code to catch it. Also adds SECURITY.md. This is a public tool that talks to an API and optionally takes a personal access token, and there was no private route for reporting a problem with it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was mir aufgefallen ist
RepoLedger rendert die Repos irgendeines GitHub-Accounts, den du eintippst, also fremde Daten. Diese Werte gingen ungefiltert in ein
innerHTML-Template. Eine Escaping-Funktion gab es im ganzen File nicht.Wie schlimm ist das
Heute nicht ausnutzbar, und das sage ich deutlich, damit es nicht dramatischer klingt als es ist. Die angezeigten Felder sind von GitHub formatbeschränkt: Repo-Namen erlauben nur
A-Za-z0-9._-, Sprachen und SPDX-Kennungen kommen aus festen Listen, der Rest sind Zahlen und Daten. Da passt kein Markup rein.Trotzdem zugemacht. Die Beschränkung, die das sicher macht, ist GitHubs, nicht die dieser Seite, und sie gilt genau für diese Felder. Wer später die Repo-Beschreibung oder die Topics in die Tabelle nimmt, beides Freitext, hätte sofort eine Injektionsstelle, und im Code stünde nichts, was sie abfängt.
Geprüft
Die Funktion gegen fünf Eingaben laufen lassen, inklusive
nullundundefined:Für dich als Nutzer: an der Anzeige ändert sich nichts. Repo-Namen und Sprachen sehen genauso aus wie vorher, weil sie keine Sonderzeichen enthalten.
Ausserdem: SECURITY.md
Das Repo hatte keine. Es ist ein öffentliches Tool, das eine API anspricht und optional einen Personal Access Token entgegennimmt, und es gab keinen privaten Weg, ein Problem damit zu melden. Die Datei beschreibt auch, was mit dem Token passiert: er bleibt in der Seite, wird nicht gespeichert und geht nur an GitHub.
Nebenwirkungen
Version 1.1.7 mit CHANGELOG-Eintrag.