diff --git a/Production/Installer/Installer/InstallerApi.py b/Production/Installer/Installer/InstallerApi.py index 2ab900d..f943d17 100644 --- a/Production/Installer/Installer/InstallerApi.py +++ b/Production/Installer/Installer/InstallerApi.py @@ -453,4 +453,5 @@ def CloseWindow(self): def LogClientError(self, Message): if isinstance(Message, str): - Logger.warning("UI: %s", Message[:300].replace("\n", " ")) + # One log line whatever the page sends: control characters (line breaks included) become spaces. + Logger.warning("UI: %s", "".join(Ch if Ch >= " " and Ch != "\x7f" else " " for Ch in Message[:300])) diff --git a/Production/Installer/Installer/Locations.py b/Production/Installer/Installer/Locations.py index ea9777e..0c9a80d 100644 --- a/Production/Installer/Installer/Locations.py +++ b/Production/Installer/Installer/Locations.py @@ -15,12 +15,15 @@ Apps list ...\\Uninstall\\RAMMIT-InstallerTest (override: RAMMIT_INSTALLER_UNINSTALL_NAME) protocol ...\\Classes\\RAMMIT-InstallerTest (override: RAMMIT_INSTALLER_PROTOCOL) folders %TEMP%\\RAMMIT-InstallerTest\\{Desktop, StartMenu, LocalAppData} (override: RAMMIT_INSTALLER_TEST_ROOT) - releases RAMMIT_INSTALLER_RELEASES_URL may point at a fake release server (ignored outside test mode) + releases RAMMIT_INSTALLER_RELEASES_URL may point at a fake release server ON THIS PC (127.0.0.1 or + localhost; ignored outside test mode, and test mode refuses to start with any other address, so + an environment variable can never make the installer download from somewhere on the network) Call Reload() after changing those environment variables (the tests do); everything else reads Current. """ import os import tempfile +import urllib.parse RealRegKeyPath = r"Software\CBlock Digital\RAMMIT" UninstallParentPath = r"Software\Microsoft\Windows\CurrentVersion\Uninstall" @@ -79,6 +82,19 @@ def _CheckTestModeIsolated(self): Problems.append("install folder") if Problems: raise RuntimeError("Test mode would touch the real " + ", ".join(Problems)) + if self.ReleasesUrlOverride and not _IsLoopbackUrl(self.ReleasesUrlOverride): + raise RuntimeError("Test mode's release server must be on this PC (http://127.0.0.1:/...)") + + +def _IsLoopbackUrl(Url): + """True for an http(s) URL whose host is this PC itself, written as 127.0.0.1, localhost or [::1].""" + try: + Parts = urllib.parse.urlsplit(Url) + Parts.port # raises ValueError for a port that isn't a number + except ValueError: + return False + return (Parts.scheme in ("http", "https") and (Parts.hostname or "") in ("127.0.0.1", "localhost", "::1") + and Parts.username is None and Parts.password is None) def _KnownFolder(Name, Fallback): diff --git a/Production/Installer/Installer/Releases.py b/Production/Installer/Installer/Releases.py index 3aa21d2..88c1e33 100644 --- a/Production/Installer/Installer/Releases.py +++ b/Production/Installer/Installer/Releases.py @@ -11,6 +11,14 @@ One API request lists every version (the old installer needed one request per commit and hit the 60-per-hour limit, which is why it carried a token). The zip is only trusted after its SHA-256 matches. +What is fetched, and nothing else: + the list https://api.github.com/repos//releases + zip + .sha256 https://github.com//releases/download/... (_CheckAssetUrl: this repo's own + release files only, whatever link the list names), which GitHub redirects to its file + hosts (AllowedDownloadHosts, checked on every redirect by _CheckUrl) +The checksum comes from the same release as the zip: it catches a damaged or swapped download, not a release +published by someone who took over the repo. Only signing the files can cover that (SECURITY.md). + Test mode can point ReleasesUrl() at a fake server (see Locations.py). """ import hashlib @@ -84,7 +92,9 @@ def ParseReleases(Data): Version = CleanVersion(str(Item.get("tag_name", ""))) if ParseVersion(Version) is None: continue - Assets = {A.get("name"): A for A in Item.get("assets", []) if isinstance(A, dict)} + RawAssets = Item.get("assets") + Assets = {A.get("name"): A for A in (RawAssets if isinstance(RawAssets, list) else []) + if isinstance(A, dict) and isinstance(A.get("name"), str)} ZipName = f"RAMMIT-{Version}.zip" Zip, Sha = Assets.get(ZipName), Assets.get(ZipName + ".sha256") if not Zip or not Sha: @@ -99,12 +109,17 @@ def ParseReleases(Data): "Published": str(Item.get("published_at") or "")[:10], "ZipName": ZipName, "ZipUrl": str(Zip.get("browser_download_url", "")), - "ZipSize": int(Zip.get("size") or 0), + "ZipSize": _Size(Zip.get("size")), "ShaUrl": str(Sha.get("browser_download_url", "")), } return sorted(Found.values(), key=lambda R: ParseVersion(R["Version"]), reverse=True) +def _Size(Value): + """An asset's size from the list, or 0 when it isn't a sensible whole number (only used for the progress bar).""" + return Value if isinstance(Value, int) and not isinstance(Value, bool) and 0 <= Value <= MaxZipBytes else 0 + + def LatestStable(ReleaseList): return next((R for R in ReleaseList if not R["Prerelease"]), None) @@ -124,10 +139,35 @@ def _CheckUrl(Url): Base = urllib.parse.urlsplit(Override) if (Parts.scheme, Parts.netloc) == (Base.scheme, Base.netloc): return - if Parts.scheme != "https" or (Parts.hostname or "") not in AllowedDownloadHosts | {"api.github.com"}: + try: + Port = Parts.port + except ValueError: + Port = -1 + if (Parts.scheme != "https" or (Parts.hostname or "") not in AllowedDownloadHosts | {"api.github.com"} + or Port not in (None, 443) or Parts.username is not None or Parts.password is not None): raise ReleaseError("A download link pointed somewhere unexpected, so it was not used.", f"refused URL host {Parts.hostname!r}") +def _CheckAssetUrl(Url): + """A release file's link (zip or .sha256) as the release list names it: only a download from this repo's own + releases on github.com (or the test override's server). The list is the only thing that says where the files + are, so without this any file on GitHub, in anyone's repo, could be named as "the RAMMIT zip" together with a + checksum that matches it.""" + _CheckUrl(Url) + Parts = urllib.parse.urlsplit(Url) + Override = Locations.Current.ReleasesUrlOverride + if Override: + Base = urllib.parse.urlsplit(Override) + if (Parts.scheme, Parts.netloc) == (Base.scheme, Base.netloc): + return + Wanted = f"/{ReleaseRepo}/releases/download/".lower() + Path = urllib.parse.unquote(Parts.path) + if ((Parts.hostname or "") != "github.com" or Parts.port is not None or Parts.username is not None + or not Path.lower().startswith(Wanted) or ".." in Path or "\\" in Path): + raise ReleaseError("A download link pointed somewhere unexpected, so it was not used.", + f"release file is not from {ReleaseRepo}'s releases: {Url[:200]!r}") + + class _CheckedRedirects(urllib.request.HTTPRedirectHandler): def redirect_request(self, Req, Fp, Code, Msg, Headers, NewUrl): _CheckUrl(NewUrl) @@ -173,6 +213,7 @@ def FetchReleases(): def FetchExpectedSha(Release): + _CheckAssetUrl(Release["ShaUrl"]) with _Open(Release["ShaUrl"], "application/octet-stream") as Response: Text = _ReadCapped(Response, MaxShaBytes).decode("ascii", "replace") return ParseShaFile(Text, Release["ZipName"]) @@ -216,6 +257,7 @@ def DownloadRelease(Release, DestDir, OnProgress=None): def _Download(Release, ZipPath, Expected, OnProgress): Done, LastReport = 0, 0.0 + _CheckAssetUrl(Release["ZipUrl"]) with _Open(Release["ZipUrl"], "application/octet-stream", Timeout=60) as Response: Total = int(Response.headers.get("Content-Length") or Release.get("ZipSize") or 0) if Total > MaxZipBytes: diff --git a/Production/Installer/Installer/UiServer.py b/Production/Installer/Installer/UiServer.py index 052adb3..8905f43 100644 --- a/Production/Installer/Installer/UiServer.py +++ b/Production/Installer/Installer/UiServer.py @@ -8,7 +8,8 @@ * 127.0.0.1 on a random free port, GET/HEAD only * any Host header other than its own address is refused (blocks DNS-rebinding pages) * exact-path lookups in the dict: no directory listings, no ../, only allowlisted file types - * every response carries a strict Content-Security-Policy, nosniff and no-store + * every response (page, scripts, images, errors) carries a strict Content-Security-Policy, nosniff and no-store + * idle connections are dropped after 15 seconds """ import http.server import os @@ -49,6 +50,7 @@ def LoadEmbeddedUi(BundleDir): class _Handler(http.server.BaseHTTPRequestHandler): server_version = "RAMMIT-Setup" sys_version = "" + timeout = 15 # seconds a connection may sit idle: a local program can't hold threads open by never sending a request def log_message(self, format, *args): # noqa: A002 - stdlib signature pass @@ -83,8 +85,9 @@ def _Send(self, Status, Body, ContentType, SendBody): self.send_header("X-Content-Type-Options", "nosniff") self.send_header("Referrer-Policy", "no-referrer") self.send_header("Cross-Origin-Resource-Policy", "same-origin") - if ContentType.startswith("text/html"): - self.send_header("Content-Security-Policy", ContentSecurityPolicy) + # On every response, not only pages: an .svg opened on its own is a document too, and would otherwise + # run any script inside it with the bridge attached. + self.send_header("Content-Security-Policy", ContentSecurityPolicy) self.end_headers() if SendBody: self.wfile.write(Body) diff --git a/Production/Installer/README.md b/Production/Installer/README.md index 89d7281..114cf90 100644 --- a/Production/Installer/README.md +++ b/Production/Installer/README.md @@ -33,7 +33,7 @@ Screenshots/ written by TestUi.mjs and SmokeExe.py $env:RAMMIT_INSTALLER_TEST = "1" # registry: HKCU\Software\CBlock Digital\RAMMIT-InstallerTest # Apps list: ...\Uninstall\RAMMIT-InstallerTest # folders: %TEMP%\RAMMIT-InstallerTest\{Desktop,StartMenu,LocalAppData} -$env:RAMMIT_INSTALLER_RELEASES_URL = "http://127.0.0.1:/repos/OWNER/RAMMIT/releases" # fake server (test mode only) +$env:RAMMIT_INSTALLER_RELEASES_URL = "http://127.0.0.1:/repos/OWNER/RAMMIT/releases" # fake server (test mode only; must be 127.0.0.1 or localhost) python Installer\Installer.py ``` diff --git a/Production/Installer/Tests/TestInstaller.py b/Production/Installer/Tests/TestInstaller.py index be54ff3..5a621ee 100644 --- a/Production/Installer/Tests/TestInstaller.py +++ b/Production/Installer/Tests/TestInstaller.py @@ -145,6 +145,57 @@ def test_download_links_to_other_hosts_are_refused(self): Releases._CheckUrl("https://github.com/OWNER/RAMMIT/releases/download/v1.0.0/RAMMIT-1.0.0.zip") Releases._CheckUrl("https://objects.githubusercontent.com/abc") + def test_release_files_must_come_from_this_repos_releases(self): + # 1.2.1: the release list names where the zip and its checksum are. Any github.com link used to be accepted, + # so a list naming a file in someone else's repo (with a checksum that matches it) would have been installed. + os.environ.pop("RAMMIT_INSTALLER_RELEASES_URL") + Locations.Reload() + Repo = Releases.ReleaseRepo + Releases._CheckAssetUrl(f"https://github.com/{Repo}/releases/download/v1.0.0/RAMMIT-1.0.0.zip") + Releases._CheckAssetUrl(f"https://github.com/{Repo.lower()}/releases/download/v1.0.0/RAMMIT-1.0.0.zip.sha256") + for Bad in ("https://github.com/someone/else/releases/download/v1.0.0/RAMMIT-1.0.0.zip", + f"https://github.com/{Repo}-evil/releases/download/v1.0.0/RAMMIT-1.0.0.zip", + f"https://github.com/{Repo}/archive/refs/heads/main.zip", + f"https://github.com/{Repo}/releases/download/../../../someone/else/x.zip", + f"https://github.com/{Repo}/releases/download/%2e%2e/%2e%2e/x.zip", + f"https://objects.githubusercontent.com/{Repo}/releases/download/v1.0.0/RAMMIT-1.0.0.zip", + f"https://api.github.com/{Repo}/releases/download/v1.0.0/RAMMIT-1.0.0.zip", + f"https://github.com:8443/{Repo}/releases/download/v1.0.0/RAMMIT-1.0.0.zip", + f"https://user@github.com/{Repo}/releases/download/v1.0.0/RAMMIT-1.0.0.zip", + f"https://github.com.evil.example/{Repo}/releases/download/v1.0.0/RAMMIT-1.0.0.zip", + f"http://github.com/{Repo}/releases/download/v1.0.0/RAMMIT-1.0.0.zip", ""): + with self.assertRaises(Releases.ReleaseError, msg=Bad): + Releases._CheckAssetUrl(Bad) + for Bad in ("https://github.com:8443/x", "https://user:pw@github.com/x", "https://github.com:bad/x"): + with self.assertRaises(Releases.ReleaseError, msg=Bad): + Releases._CheckUrl(Bad) + + def test_a_list_naming_another_repos_file_installs_nothing(self): + Elsewhere = "https://github.com/someone/else/releases/download/v1.0.0/RAMMIT-1.0.0.zip" + Release = dict(Releases.FindRelease(Releases.FetchReleases(), "1.0.0")) + os.environ.pop("RAMMIT_INSTALLER_RELEASES_URL") + Locations.Reload() # as a real installer: no test server to trust + for Swapped in ({"ZipUrl": Elsewhere}, {"ShaUrl": Elsewhere + ".sha256"}): + with mock.patch.object(Releases, "_Open") as Open, self.assertRaises(Releases.ReleaseError): + if "ShaUrl" in Swapped: + Releases.FetchExpectedSha(dict(Release, **Swapped)) + else: + Releases._Download(dict(Release, **Swapped), os.path.join(self.Env.Root, "x.zip"), "0" * 64, None) + Open.assert_not_called() # refused before any request is made + self.assertFalse(os.path.exists(os.path.join(self.Env.Root, "x.zip"))) + + def test_odd_release_lists_never_crash(self): + def Rel(**Extra): + Assets = [{"name": "RAMMIT-1.0.0.zip", "browser_download_url": "https://github.com/o/r/a.zip", "size": 10}, + {"name": "RAMMIT-1.0.0.zip.sha256", "browser_download_url": "https://github.com/o/r/a.sha256"}] + return dict({"tag_name": "v1.0.0", "assets": Assets}, **Extra) + self.assertEqual(Releases.ParseReleases([Rel(assets=None), Rel(assets="x"), Rel(assets={"a": 1}), Rel(assets=[5, None])]), []) + for Size in ("big", -1, 1.5, True, None, [1], 10 ** 30): + Odd = Rel() + Odd["assets"][0]["size"] = Size + self.assertEqual(Releases.ParseReleases([Odd])[0]["ZipSize"], 0, Size) + self.assertEqual(Releases.ParseReleases([Rel()])[0]["ZipSize"], 10) + def test_offline_gives_a_friendly_error(self): self.Server.Offline = True with self.assertRaises(Releases.ReleaseError) as Caught: @@ -838,7 +889,33 @@ def test_release_override_ignored_outside_test_mode(self): self.assertTrue(Releases.ReleasesUrl().startswith("https://api.github.com/repos/")) + def test_test_mode_release_server_must_be_on_this_pc(self): + # 1.2.1: test mode is switched on by environment variables, which the released RAMMIT-Setup.exe reads too. + # Its fake release server may only be on this PC, so those variables can't point a download at the network. + os.environ["RAMMIT_INSTALLER_TEST"] = "1" + for Bad in ("http://evil.example/repos/o/r/releases", "https://evil.example/x", "http://127.0.0.1.evil.example/x", + "http://user@127.0.0.1:8000/x", "ftp://127.0.0.1/x", "http://10.0.0.5:8000/x", "//127.0.0.1/x", + "http://127.0.0.1:bad/x"): + os.environ["RAMMIT_INSTALLER_RELEASES_URL"] = Bad + with self.assertRaises(RuntimeError, msg=Bad): + Locations.Reload() + for Good in ("http://127.0.0.1:8000/repos/o/r/releases", "http://localhost:8000/x", "http://[::1]:8000/x"): + os.environ["RAMMIT_INSTALLER_RELEASES_URL"] = Good + self.assertEqual(Locations.Reload().ReleasesUrlOverride, Good) + + class TestApiSurface(InstallerTestCase): + def test_client_errors_are_logged_on_one_line(self): + Api = InstallerApi.InstallerApi() + with mock.patch.object(InstallerApi.Logger, "warning") as Warn: + Api.LogClientError("boom\r\n2026-11-10 12:00:00 INFO Install finished\x1b[2J\x00" + "x" * 500) + Api.LogClientError(["not", "text"]) + Warn.assert_called_once() + Text = Warn.call_args.args[1] + self.assertFalse(any(Ch < " " or Ch == "\x7f" for Ch in Text), repr(Text[:60])) + self.assertLessEqual(len(Text), 300) + self.assertTrue(Text.startswith("boom 2026-11-10")) + def test_no_public_state_and_bad_arguments_return_errors(self): Api = InstallerApi.InstallerApi() Api._AttachWindow(Support.EventWindow()) @@ -926,6 +1003,17 @@ def Get(self, Path, Host=None, Method="GET"): Connection.close() return Response.status, dict(Response.getheaders()), Body + def test_every_response_carries_the_policy(self): + # 1.2.1: also scripts, images and errors, not only the page (an .svg opened on its own is a document too). + for Path, Wanted in (("/JS/Installer.js", 200), ("/RAMMIT-Downloader.png", 200), ("/nope.svg", 404)): + Status, Headers, _Body = self.Get(Path) + self.assertEqual(Status, Wanted, Path) + self.assertIn("script-src 'self'", Headers.get("Content-Security-Policy", ""), Path) + Status, Headers, _Body = self.Get("/HTML/Installer.html", Host="evil.example") + self.assertEqual(Status, 403) + self.assertIn("default-src 'none'", Headers.get("Content-Security-Policy", "")) + self.assertTrue(0 < UiServer._Handler.timeout <= 60) # idle connections are dropped + def test_hardening(self): Status, Headers, Body = self.Get("/HTML/Installer.html") self.assertEqual(Status, 200) diff --git a/Production/Installer/Workflow/Release.yml b/Production/Installer/Workflow/Release.yml index fdaf97d..95eb7a4 100644 --- a/Production/Installer/Workflow/Release.yml +++ b/Production/Installer/Workflow/Release.yml @@ -4,6 +4,9 @@ # * the paths assume the repo layout App/, Src/, Tests/, Tools/, Installer/, Installer.spec at the root # (today: Production/RAMMIT-Stable + Production/Installer) # * requirements.txt must pin exact versions with hashes (pip --require-hashes) +# * never write ${{ github.ref_name }} (or any other ${{ ... }} a pusher controls) inside a run: script. GitHub +# pastes it into the script before PowerShell reads it, so a tag named v1";;" would run +# with this job's write token. The steps below read it from $env:TagName / $env:GitRef instead. # # Tag push v1.2.3 -> checks, build, smoke test, DRAFT release with the three assets. # Any other push -> the same checks and build, no release. @@ -63,13 +66,17 @@ jobs: - name: Tag must equal App/Version.py if: startsWith(github.ref, 'refs/tags/v') + env: + TagName: ${{ github.ref_name }} run: | $Version = (python -c "from App.Version import AppVersion; print(AppVersion)").Trim() - if ("v$Version" -ne "${{ github.ref_name }}") { throw "tag ${{ github.ref_name }} != App/Version.py v$Version" } + if ("v$Version" -cne $env:TagName) { throw "tag $($env:TagName) != App/Version.py v$Version" } - name: Build app zip + .sha256, and RAMMIT-Setup.exe + env: + GitRef: ${{ github.ref }} run: | - $Channel = if ("${{ github.ref }}".StartsWith("refs/tags/v")) { "Stable" } else { "Dev" } + $Channel = if ($env:GitRef.StartsWith("refs/tags/v")) { "Stable" } else { "Dev" } ./Build.ps1 -SkipChecks -Channel $Channel if ($LASTEXITCODE) { throw "Build.ps1" } $env:RAMMIT_VERSION_FILE = "$PWD/App/Version.py" @@ -93,8 +100,11 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') env: GH_TOKEN: ${{ github.token }} + TagName: ${{ github.ref_name }} run: | - $Version = "${{ github.ref_name }}".TrimStart("v") - $Pre = if ($Version.Contains("-")) { "--prerelease" } else { "" } - gh release create "${{ github.ref_name }}" --draft $Pre --title "RAMMIT $Version" --generate-notes ` - "dist/RAMMIT-Setup.exe" "dist/RAMMIT-$Version.zip" "dist/RAMMIT-$Version.zip.sha256" + # The tag equals "v" + App/Version.py (checked above), so the version is read from there, not from the tag. + $Version = (python -c "from App.Version import AppVersion; print(AppVersion)").Trim() + $Arguments = @($env:TagName, "--draft", "--title", "RAMMIT $Version", "--generate-notes") + if ($Version.Contains("-")) { $Arguments += "--prerelease" } + gh release create @Arguments "dist/RAMMIT-Setup.exe" "dist/RAMMIT-$Version.zip" "dist/RAMMIT-$Version.zip.sha256" + if ($LASTEXITCODE) { throw "gh release create" } diff --git a/Production/RAMMIT-Stable/App/Api.py b/Production/RAMMIT-Stable/App/Api.py index 9c59ba1..80e1c5a 100644 --- a/Production/RAMMIT-Stable/App/Api.py +++ b/Production/RAMMIT-Stable/App/Api.py @@ -17,7 +17,7 @@ from App import MultiInstance, Roblox, Storage, Themes from App.Log import Logger -from App.Version import AppChannel, AppName, AppVersion, VersionLabel +from App.Version import AppChannel, AppCodeName, AppName, AppVersion, VersionLabel from App.WindowSize import HeldWindow LockedLoginMessage = "This saved login can't be read on this PC or Windows user. Remove the account and add it again." @@ -93,7 +93,7 @@ def BootFinished(self): self._Splash.Dismiss() def GetAppInfo(self): - return {"Name": AppName, "Version": AppVersion, "Channel": AppChannel, "Label": VersionLabel()} + return {"Name": AppName, "Version": AppVersion, "Channel": AppChannel, "Label": VersionLabel(), "CodeName": AppCodeName} def LogClientError(self, Message): Logger.warning("UI: %s", Storage.CleanText(Message, 300) if isinstance(Message, str) else "non-text error") @@ -172,9 +172,18 @@ def _PollLogin(self, Window, RenewFor=None, Done=None, Outcome=None): @staticmethod def _FindLoginCookie(CookieJars): + """The Roblox login cookie from the login window, or None. Only a cookie Roblox itself set counts: the login + window can end up on another site (a link on the page, a redirect), and that site could set a cookie with + the same name to get its own account saved here. A cookie with no domain recorded is taken as before.""" for Jar in CookieJars or []: for Name, Morsel in Jar.items(): - if Name == ".ROBLOSECURITY" and Morsel.value: + if Name != ".ROBLOSECURITY" or not isinstance(Morsel.value, str) or not Morsel.value: + continue + try: + Domain = Morsel["domain"] + except (KeyError, TypeError): + Domain = "" + if Roblox.IsRobloxCookieDomain(Domain) and Roblox.IsCookieValue(Morsel.value): return Morsel.value return None diff --git a/Production/RAMMIT-Stable/App/LocalServer.py b/Production/RAMMIT-Stable/App/LocalServer.py index 889f0a0..31fd0fc 100644 --- a/Production/RAMMIT-Stable/App/LocalServer.py +++ b/Production/RAMMIT-Stable/App/LocalServer.py @@ -4,7 +4,8 @@ * binds to 127.0.0.1 on a random free port, GET/HEAD only * rejects any Host header other than its own address (blocks DNS-rebinding pages) * no directory listings, only an allowlist of file types, no paths outside Src/ - * every response carries a strict Content-Security-Policy, nosniff and no-store + * every response (pages, scripts, images, errors) carries a strict Content-Security-Policy, nosniff and no-store + * idle connections are dropped after 15 seconds The web root is the active theme's folder (Src//, see App/Themes.py), looked up on every request, so switching theme is just "save the setting, reload the page". @@ -33,6 +34,7 @@ class _Handler(http.server.BaseHTTPRequestHandler): server_version = "RAMMIT" sys_version = "" + timeout = 15 # seconds a connection may sit idle: a local program can't hold threads open by never sending a request def log_message(self, format, *args): # noqa: A002 - stdlib signature pass @@ -78,8 +80,9 @@ def _Send(self, Status, Body, ContentType, SendBody): self.send_header("X-Content-Type-Options", "nosniff") self.send_header("Referrer-Policy", "no-referrer") self.send_header("Cross-Origin-Resource-Policy", "same-origin") - if ContentType.startswith("text/html"): - self.send_header("Content-Security-Policy", ContentSecurityPolicy) + # On every response, not only pages: an .svg opened on its own is a document too, and would otherwise + # run any script inside it with the bridge attached. + self.send_header("Content-Security-Policy", ContentSecurityPolicy) self.end_headers() if SendBody: self.wfile.write(Body) diff --git a/Production/RAMMIT-Stable/App/Main.py b/Production/RAMMIT-Stable/App/Main.py index c14e2dc..a333a16 100644 --- a/Production/RAMMIT-Stable/App/Main.py +++ b/Production/RAMMIT-Stable/App/Main.py @@ -9,7 +9,7 @@ from App.Api import Api, GuardNavigation from App.LocalServer import LocalServer from App.Log import Logger, Setup as SetupLog -from App.Version import VersionLabel +from App.Version import AppCodeName, VersionLabel WindowWidth, WindowScale = 900, 0.85 @@ -27,7 +27,7 @@ def StartHeight(Bridge): def Run(): SetupLog() - Logger.info("RAMMIT %s starting from %s", VersionLabel(), Paths.BaseDir) + Logger.info("RAMMIT %s (%s) starting from %s", VersionLabel(), AppCodeName, Paths.BaseDir) if getattr(sys, "frozen", False): # only the installed exe: running from source never touches the registry try: Done = Install.Sync(Paths.BaseDir) diff --git a/Production/RAMMIT-Stable/App/Roblox.py b/Production/RAMMIT-Stable/App/Roblox.py index 9b420e0..3524add 100644 --- a/Production/RAMMIT-Stable/App/Roblox.py +++ b/Production/RAMMIT-Stable/App/Roblox.py @@ -4,7 +4,8 @@ * Every id that ends up in a URL or in the roblox-player: launch URI is validated first (PlaceId digits, JobId UUID, link codes [A-Za-z0-9_-]). The launch URI uses "+" as its field separator, so an unvalidated value could inject extra launch arguments. - * Every request has a timeout. Cookies are only ever sent to *.roblox.com over HTTPS. + * Every request has a timeout. Cookies are only ever sent to *.roblox.com over HTTPS, and no request + follows a redirect (NoRedirect), so a login never travels to wherever an answer points. * Never log a cookie, auth ticket or launch URI. """ import os @@ -20,6 +21,7 @@ from App.Log import Logger Timeout = 10 +NoRedirect = {"allow_redirects": False} # passed to every request: see the rules above MaxServerPages = 10 # 10 x 100 servers is plenty to pick from; huge games have 1000s of pages PlayerExe = "RobloxPlayerBeta.exe" @@ -52,6 +54,23 @@ def IsJobId(Value): return isinstance(Value, str) and bool(JobIdPattern.match(Value)) +def IsRobloxCookieDomain(Domain): + """True for roblox.com and its subdomains (".roblox.com", "www.roblox.com"), and for an empty domain (the + browser didn't record one). Anything else is another site's cookie.""" + if not Domain: + return True + if not isinstance(Domain, str): + return False + Host = Domain.strip().lstrip(".").lower() + return Host == "roblox.com" or Host.endswith(".roblox.com") + + +def IsCookieValue(Value): + """A cookie value that can go into a Cookie header as it is: printable ASCII with no space, line break or ";" + (which would end the cookie and start another).""" + return isinstance(Value, str) and 0 < len(Value) <= 8192 and all(" " < Ch < "\x7f" and Ch != ";" for Ch in Value) + + def PlaceIdFromGameUrl(Url): Match = GameUrlPattern.search(Url or "") return Match.group(1) if Match else None @@ -66,7 +85,7 @@ def CheckLogin(Cookie): """("Valid", (UserId, Username, DisplayName)), ("Expired", None) when Roblox rejects the login (401), or ("Unknown", None) for anything else (offline, rate limited, ...), so a bad connection never marks a login expired.""" try: - Response = requests.get("https://users.roblox.com/v1/users/authenticated", headers=_CookieHeader(Cookie), timeout=Timeout) + Response = requests.get("https://users.roblox.com/v1/users/authenticated", headers=_CookieHeader(Cookie), timeout=Timeout, **NoRedirect) if Response.status_code == 401: return "Expired", None if Response.status_code != 200: @@ -87,7 +106,7 @@ def GetAuthTicket(Cookie): Headers = {"User-Agent": "Roblox/WinInet", "Referer": "https://www.roblox.com/develop", "RBX-For-Gameauth": "true", "Content-Type": "application/json", **_CookieHeader(Cookie)} try: - First = requests.post(Url, headers=Headers, timeout=Timeout) + First = requests.post(Url, headers=Headers, timeout=Timeout, **NoRedirect) Csrf = First.headers.get("x-csrf-token") if First.status_code == 401: return LoginExpired @@ -96,7 +115,7 @@ def GetAuthTicket(Cookie): return None Headers["X-CSRF-TOKEN"] = Csrf for Attempt in range(4): - Second = requests.post(Url, headers=Headers, timeout=Timeout) + Second = requests.post(Url, headers=Headers, timeout=Timeout, **NoRedirect) if Second.status_code == 200: return Second.headers.get("rbx-authentication-ticket") or None if Second.status_code == 401: @@ -124,7 +143,7 @@ def FetchServers(PlaceId, Cookie=None, MaxPages=MaxServerPages): Query["cursor"] = Cursor Url = f"https://games.roblox.com/v1/games/{PlaceId}/servers/Public?" + urllib.parse.urlencode(Query) try: - Response = requests.get(Url, headers=Headers, timeout=Timeout) + Response = requests.get(Url, headers=Headers, timeout=Timeout, **NoRedirect) if Response.status_code == 429 and Servers: break # rate limited mid-way: use what we have if Response.status_code != 200: @@ -155,6 +174,10 @@ def PickServer(Servers, PlayerMode="any", PingMode="any", MinPlayers=0, MaxPlaye def Playing(S): return S.get("playing") if isinstance(S.get("playing"), int) else 0 + def Ping(S, Missing): # a ping that isn't a number must not crash the sort + Value = S.get("ping") + return Value if isinstance(Value, (int, float)) and not isinstance(Value, bool) else Missing + Open = [S for S in Servers if isinstance(S.get("maxPlayers"), int) and Playing(S) < S["maxPlayers"] and IsJobId(S.get("id", ""))] if PlayerMode == "range": Open = [S for S in Open if MinPlayers <= Playing(S) <= MaxPlayers] @@ -166,9 +189,9 @@ def Playing(S): return None # Ping order first, so it breaks ties for smallest/biggest and picks the winner otherwise. if PingMode == "lowest": - Open.sort(key=lambda S: S.get("ping", 9999)) + Open.sort(key=lambda S: Ping(S, 9999)) elif PingMode == "highest": - Open.sort(key=lambda S: -S.get("ping", 0)) + Open.sort(key=lambda S: -Ping(S, 0)) if PlayerMode == "smallest": return min(Open, key=Playing) if PlayerMode == "biggest": @@ -192,10 +215,10 @@ def ResolveVipLink(UrlOrCode, Cookie=None): Headers = {"Content-Type": "application/json", **_CookieHeader(Cookie)} for Payload in ({"linkId": Code, "linkType": "Server"}, {"code": Code, "type": "Server"}): try: - Response = requests.post(Url, headers=Headers, json=Payload, timeout=Timeout) + Response = requests.post(Url, headers=Headers, json=Payload, timeout=Timeout, **NoRedirect) if Response.status_code == 403 and Response.headers.get("x-csrf-token"): Headers["X-CSRF-TOKEN"] = Response.headers["x-csrf-token"] - Response = requests.post(Url, headers=Headers, json=Payload, timeout=Timeout) + Response = requests.post(Url, headers=Headers, json=Payload, timeout=Timeout, **NoRedirect) if Response.status_code != 200: continue Raw = Response.text diff --git a/Production/RAMMIT-Stable/App/Storage.py b/Production/RAMMIT-Stable/App/Storage.py index 468efaa..c3530b8 100644 --- a/Production/RAMMIT-Stable/App/Storage.py +++ b/Production/RAMMIT-Stable/App/Storage.py @@ -291,7 +291,7 @@ def LoadAccounts(): try: Cookie = Crypto.Decrypt(Stored) except Crypto.DecryptError: - Logger.warning("Saved login for %s cannot be decrypted on this PC/user", Entry["username"]) + Logger.warning("Saved login for %s cannot be decrypted on this PC/user", CleanText(Entry["username"], 50)) Cookie = None else: Cookie = Stored diff --git a/Production/RAMMIT-Stable/App/Themes.py b/Production/RAMMIT-Stable/App/Themes.py index 36986bd..8a6ddad 100644 --- a/Production/RAMMIT-Stable/App/Themes.py +++ b/Production/RAMMIT-Stable/App/Themes.py @@ -279,6 +279,13 @@ def _ToHex(Color): """#rrggbb for any colour the swatch accepts (hex, rgb(a), hsl(a), CSS colour names), else None. The window background and the start-up spinner need plain hex, and converting every swatch colour keeps them identical to the swatch the user sees.""" + try: + return _ToHexUnchecked(Color) + except (ValueError, OverflowError): # e.g. hsl(1.2.3, ...): a theme's odd colour must never stop RAMMIT starting + return None + + +def _ToHexUnchecked(Color): Color = (Color or "").strip() if re.fullmatch(r"#[0-9a-fA-F]{3,4}", Color): return "#" + "".join(Ch * 2 for Ch in Color[1:4]) diff --git a/Production/RAMMIT-Stable/App/Version.py b/Production/RAMMIT-Stable/App/Version.py index 927cb1b..82552fa 100644 --- a/Production/RAMMIT-Stable/App/Version.py +++ b/Production/RAMMIT-Stable/App/Version.py @@ -7,7 +7,8 @@ """ AppName = "RAMMIT" -AppVersion = "1.2.0" +AppVersion = "1.2.1" +AppCodeName = "Blessed Frank" # this release's code name (the changelog, the log's first line, GetAppInfo) try: from App.BuildInfo import AppChannel, AppCommit diff --git a/Production/RAMMIT-Stable/CHANGELOG.md b/Production/RAMMIT-Stable/CHANGELOG.md index c4f2fbd..8e1ef0c 100644 --- a/Production/RAMMIT-Stable/CHANGELOG.md +++ b/Production/RAMMIT-Stable/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 1.2.1 "Blessed Frank" (2026-11) + +A security release: a second audit of the app, the installer, the release workflow and the website. Nothing changes in how RAMMIT is used. Details and what was checked: [SECURITY.md](SECURITY.md) › "1.2.1 audit". + +- **Login window:** only a login cookie set by Roblox itself is saved. Before, a cookie with Roblox's name from any site the login window ended up on (a link on the page, a redirect) was accepted, so another site could get its own account saved in RAMMIT in place of yours. +- **Saved logins never follow a redirect.** Every request RAMMIT makes to Roblox now stops at the address it asked for, so a login can't travel on to wherever an answer points. +- **Installer:** the zip and its checksum are only downloaded from this repo's own releases (`github.com/CBlockDigital/RAMMIT/releases/download/...`). Before, any `github.com` link in the release list was accepted, so a list naming a file in someone else's repo, with a checksum that matched it, would have been installed. Links with a port or a user name in them are refused too. +- **Installer:** test mode's fake release server must be on this PC (`127.0.0.1` / `localhost`). Test mode is switched on with environment variables, which the released `RAMMIT-Setup.exe` reads as well; they can no longer point a download at a server on the network. +- **Local UI servers (app and installer):** the Content-Security-Policy is sent with every response, not only pages (an `.svg` opened on its own could run its own script), and idle connections are dropped after 15 seconds. +- **Themes:** a colour like `hsl(1.2.3, 5%, 5%)` in a theme's `Style.css` no longer stops RAMMIT from starting; that slot falls back to the default colour. +- A server list with a ping that isn't a number no longer fails the launch. +- **Installer:** a release list with odd contents (assets that aren't a list, a size that isn't a number) is skipped over instead of raising an error, and messages the page sends to `Setup.log` are always one line. +- **Release workflow draft** (`Production/Installer/Workflow/Release.yml`): the tag name is read from the environment instead of being pasted into the scripts, where a tag named like a command would have run with the job's write token. +- **Website:** a Content-Security-Policy (only the site's own files and the Google font load), and the version shown is 1.2.1. +- The version's code name is in `App/Version.py` (`AppCodeName`), the first line of `RAMMIT.log`, and the tooltip of the version line in Settings. The line itself still reads `RAMMIT v1.2.1 · Stable`. +- Custom themes: nothing to change. To get the code-name tooltip in a theme of your own, copy Dark's `JS\Main.js` into it. + ## 1.2.0 (2026-11) - **Installer:** the window no longer stays at the Loading screen's height. Grabbing or dragging the title bar while the screen changed undid the resize; a resize that arrives while the window is held now waits and is applied once when you let go. Two resizes sent close together could also finish in the wrong order and leave the window at the older height; they are now sent one at a time, and only the newest waiting one is sent, so the newest height always wins (#8). diff --git a/Production/RAMMIT-Stable/Docs/HowToMakeATheme.txt b/Production/RAMMIT-Stable/Docs/HowToMakeATheme.txt index 478aa0b..a82318f 100644 --- a/Production/RAMMIT-Stable/Docs/HowToMakeATheme.txt +++ b/Production/RAMMIT-Stable/Docs/HowToMakeATheme.txt @@ -42,7 +42,7 @@ press the "?" button, then "Making your own theme". "SupportedVersions" says which RAMMIT versions your theme was made for. The version is at the bottom of the Settings panel - (for example "RAMMIT v1.2.0 - Stable"). + (for example "RAMMIT v1.2.1 - Stable"). "1.0" any 1.0.x (1.0.0, 1.0.1, ...) "1.0.2" exactly 1.0.2 "1.2+" 1.2.0 and everything newer diff --git a/Production/RAMMIT-Stable/Docs/README.txt b/Production/RAMMIT-Stable/Docs/README.txt index 46306b9..f9f2d61 100644 --- a/Production/RAMMIT-Stable/Docs/README.txt +++ b/Production/RAMMIT-Stable/Docs/README.txt @@ -1,5 +1,5 @@ ======================================================== - RAMMIT - Roblox Multi-Account Launcher (v1.2.0) + RAMMIT - Roblox Multi-Account Launcher (v1.2.1) Setup Guide (read this first) ======================================================== @@ -10,7 +10,7 @@ them at the same time on one PC. You do NOT need Python or any other program installed - everything RAMMIT needs is inside this folder. The bottom of the Settings panel shows your version, for example -"RAMMIT v1.2.0 · Stable". Please include it when you report a problem. +"RAMMIT v1.2.1 · Stable". Please include it when you report a problem. WHAT YOU NEED diff --git a/Production/RAMMIT-Stable/SECURITY.md b/Production/RAMMIT-Stable/SECURITY.md index 9c74941..d15a99c 100644 --- a/Production/RAMMIT-Stable/SECURITY.md +++ b/Production/RAMMIT-Stable/SECURITY.md @@ -43,3 +43,44 @@ is still the only guarantee. - `requests` talks to `*.roblox.com` only; certificate validation is left at its secure default. - DPAPI protects against file theft, not against malware already running as the same Windows user. + +--- + +# 1.2.1 audit ("Blessed Frank", 2026-11-10) + +**Subject:** `Production/RAMMIT-Stable` (app), `Production/Installer` (RAMMIT-Setup, the update path), `.github/workflows/CI.yml`, the release workflow draft and `Web/Website`, at 1.2.0 (commit `5988b8d`). +**Method:** line-by-line review of every Python module, the bridge-facing JavaScript, both workflows and the website. Each fix has a test in `Tests/TestBackend.py` or `Production/Installer/Tests/TestInstaller.py`. The tests were written and run on Linux with stand-ins for the Windows-only modules; **the full Windows suites and the real exe have not been run for this release yet** (CI runs them on the pull request). + +## Findings and fixes + +| # | Severity | Finding (1.2.0) | Fix (1.2.1) | +|---|---|---|---| +| F1 | Medium | **Installer: release files accepted from any GitHub repo.** The release list says where the zip and its `.sha256` are; any `https://github.com/...` link passed `_CheckUrl`. A list naming a file in someone else's repo, plus a checksum matching it, would have been downloaded, "verified" and installed. Needs a forged list (a broken TLS connection, or control of the list in some other way). | `Releases._CheckAssetUrl`: the zip and checksum must be under `github.com/CBlockDigital/RAMMIT/releases/download/`, checked before any request. Redirects are still limited to GitHub's file hosts. URLs with a port or user name are refused. | +| F2 | Medium | **Login window: a cookie from any site counted as the Roblox login.** `_FindLoginCookie` took the first `.ROBLOSECURITY` cookie whatever its domain. The login window is an ordinary browser window, so a site it ended up on could set that cookie and have *its* account saved (the user then plays, buys or trades on an account someone else controls). | Only a cookie whose domain is `roblox.com` or a subdomain counts, and its value must be printable with no `;` or line break (`Roblox.IsRobloxCookieDomain`, `IsCookieValue`). | +| F3 | Low | **Installer test mode could download from the network.** `RAMMIT_INSTALLER_TEST=1` + `RAMMIT_INSTALLER_RELEASES_URL` work in the released exe too and allowed any host over plain `http`. Needs control of the user's environment variables; installs go to the test folders, but the downloaded `RAMMIT.exe` can be launched from the done screen. | The override must be `127.0.0.1`, `localhost` or `[::1]`; test mode refuses to start otherwise. | +| F4 | Low | **Release workflow draft: script injection through the tag name.** `${{ github.ref_name }}` was pasted into `run:` scripts in a job holding `contents: write`. A tag such as `v1";;"` would have run ``. Needs push access; the file is a draft, not yet under `.github/workflows/`. | The tag and ref are passed through `env:` and the version is read from `App/Version.py`. | +| F5 | Low | **Local UI servers:** the CSP was only sent with `.html`. An `.svg` in a theme folder, opened as a document, ran its script without it. No idle timeout, so a local program could hold the server's threads open. | CSP on every response (also errors); 15 s idle timeout. App and installer. | +| F6 | Low | **A theme colour could stop RAMMIT starting.** `hsl(1.2.3, 5%, 5%)` passed the swatch pattern, then `float()` raised while the window colour was worked out, before the window existed. | `Themes._ToHex` returns no colour for it; the default is used. | +| F7 | Low | **Defence in depth: requests followed redirects.** `requests` drops a hand-set `Cookie` header on a redirect, so no login leaked, but the CSRF token and the rest travelled on, and it relied on a library detail. | Every request passes `allow_redirects=False`; a test counts the calls so a new one can't forget it. | +| F8 | Info | A non-numeric `ping` raised inside the server sort (launch failed with "Launch failed (TypeError)"). An odd release list (`assets` not a list, `size` not a number) raised out of `ListVersions`. `LogClientError` in the installer let `\r` and other control characters into `Setup.log`; a user name read from `Accounts.json` was logged unchecked. | All handled; log lines are single lines. | +| F9 | Info | The website had no Content-Security-Policy and showed v1.1.1. | CSP `` (own files + the Google font; the one inline script by hash), checked in headless Chrome with a deliberately wrong hash as the control. | + +## Checked and found sound + +- Zip extraction (`Setup.ExtractToStaging`): path escapes, device names, zip bombs, reserved names, staging marker. +- Swap, rollback, manifest-only uninstall, backups never following links. +- Bridge inputs in `Api.py` and `InstallerApi.py`: validated, state private, errors returned. +- `roblox-player:` URI building, registry channel, DPAPI storage, atomic writes, the log rule. +- DOM building in every theme and the installer page (`El` / `textContent`; the one `innerHTML` is static tour text). +- `RAMMIT:` protocol: nothing from the link reaches RAMMIT. +- CI: actions pinned to commit SHAs, `contents: read`, no credentials kept. +- Pinned packages against published advisories on 2026-11-10 (web search, not `pip-audit`: package installs were unavailable where the audit ran): requests 2.33.1 is past CVE-2026-25645 (fixed in 2.33.0) and CVE-2024-47081; PyInstaller 6.22.3 is past CVE-2025-59042; nothing found for pywebview 6.2.1, pywin32 312 or psutil 7.2.2. Run `pip-audit -r requirements.txt` before the release. + +## Still open (not fixable in code alone) + +- **The checksum is not a signature.** The `.sha256` sits next to the zip in the same release, so it catches a damaged or swapped download but not a release published from a taken-over GitHub account. Protect the account (2FA, no long-lived tokens), keep releases as drafts until checked, and sign the exe and zip when a certificate is available. The exe is still **unsigned**. +- **`requirements.txt` has no hashes** and CI installs without `--require-hashes`. Generate them on Windows (`pip-compile --generate-hashes`) before the release workflow is switched on. +- **Install folder outside the user profile.** `%LOCALAPPDATA%\RAMMIT` is private to the Windows user. A folder such as `D:\RAMMIT` is usually writable by every user of the PC, who could then change `RAMMIT.exe` or a theme's JavaScript there. Saved logins stay unreadable to them (DPAPI). On a shared PC, keep the default folder. +- **`GuardNavigation` acts after the page has loaded**, so a page the main window reached would have the bridge for a moment. Nothing in the UI can navigate away (CSP, no links, no forms); stopping it earlier needs WebView2's `NavigationStarting`, which needs testing on Windows. +- **The launch ticket is on Roblox's command line** (that is how Roblox takes it), readable by other programs of the same Windows user for the seconds it is valid. +- Unchanged from the first audit: themes are trusted code; DPAPI doesn't protect against malware already running as the same Windows user. diff --git a/Production/RAMMIT-Stable/Src/CBlock/JS/Main.js b/Production/RAMMIT-Stable/Src/CBlock/JS/Main.js index 49c21fd..329fcee 100644 --- a/Production/RAMMIT-Stable/Src/CBlock/JS/Main.js +++ b/Production/RAMMIT-Stable/Src/CBlock/JS/Main.js @@ -48,6 +48,7 @@ async function Boot() { InitTours(Settings.ToursDone); const Info = await Api.GetAppInfo(); ById('AppVersion').textContent = `${Info.Name} ${Info.Label}`; + if (Info.CodeName) ById('AppVersion').title = `Code name: ${Info.CodeName}`; // themed tooltip (Tooltip.js) }); StartCounterLoop(); // Everything is loaded: let the native start-up spinner (App/Splash.py) fade out. diff --git a/Production/RAMMIT-Stable/Src/Dark/JS/Main.js b/Production/RAMMIT-Stable/Src/Dark/JS/Main.js index 49c21fd..329fcee 100644 --- a/Production/RAMMIT-Stable/Src/Dark/JS/Main.js +++ b/Production/RAMMIT-Stable/Src/Dark/JS/Main.js @@ -48,6 +48,7 @@ async function Boot() { InitTours(Settings.ToursDone); const Info = await Api.GetAppInfo(); ById('AppVersion').textContent = `${Info.Name} ${Info.Label}`; + if (Info.CodeName) ById('AppVersion').title = `Code name: ${Info.CodeName}`; // themed tooltip (Tooltip.js) }); StartCounterLoop(); // Everything is loaded: let the native start-up spinner (App/Splash.py) fade out. diff --git a/Production/RAMMIT-Stable/Src/Light/JS/Main.js b/Production/RAMMIT-Stable/Src/Light/JS/Main.js index 49c21fd..329fcee 100644 --- a/Production/RAMMIT-Stable/Src/Light/JS/Main.js +++ b/Production/RAMMIT-Stable/Src/Light/JS/Main.js @@ -48,6 +48,7 @@ async function Boot() { InitTours(Settings.ToursDone); const Info = await Api.GetAppInfo(); ById('AppVersion').textContent = `${Info.Name} ${Info.Label}`; + if (Info.CodeName) ById('AppVersion').title = `Code name: ${Info.CodeName}`; // themed tooltip (Tooltip.js) }); StartCounterLoop(); // Everything is loaded: let the native start-up spinner (App/Splash.py) fade out. diff --git a/Production/RAMMIT-Stable/Src/MyCustomTheme/JS/Main.js b/Production/RAMMIT-Stable/Src/MyCustomTheme/JS/Main.js index 49c21fd..329fcee 100644 --- a/Production/RAMMIT-Stable/Src/MyCustomTheme/JS/Main.js +++ b/Production/RAMMIT-Stable/Src/MyCustomTheme/JS/Main.js @@ -48,6 +48,7 @@ async function Boot() { InitTours(Settings.ToursDone); const Info = await Api.GetAppInfo(); ById('AppVersion').textContent = `${Info.Name} ${Info.Label}`; + if (Info.CodeName) ById('AppVersion').title = `Code name: ${Info.CodeName}`; // themed tooltip (Tooltip.js) }); StartCounterLoop(); // Everything is loaded: let the native start-up spinner (App/Splash.py) fade out. diff --git a/Production/RAMMIT-Stable/Tests/TestBackend.py b/Production/RAMMIT-Stable/Tests/TestBackend.py index ee7d441..ac20836 100644 --- a/Production/RAMMIT-Stable/Tests/TestBackend.py +++ b/Production/RAMMIT-Stable/Tests/TestBackend.py @@ -314,6 +314,47 @@ def FakeGet(Url, **_Kw): self.assertEqual(Roblox.FetchServers("1/../2"), []) Get.assert_not_called() + def test_NoRequestFollowsARedirect(self): + # 1.2.1: a saved login is only ever sent to the Roblox address RAMMIT asked for, never on to wherever an + # answer redirects. Every request in Roblox.py must pass allow_redirects=False. + Seen = [] + + def Fake(Url, **Kw): + Seen.append((Url, Kw.get("allow_redirects"), Kw.get("timeout"))) + return mock.Mock(status_code=302, headers={"Location": "https://evil.example/", "x-csrf-token": "c"}, + text="", json=lambda: {}) + with mock.patch.object(Roblox.requests, "get", Fake), mock.patch.object(Roblox.requests, "post", Fake), \ + mock.patch("App.Roblox.time.sleep"): + self.assertEqual(Roblox.CheckLogin("fake"), ("Unknown", None)) + self.assertIsNone(Roblox.GetAuthTicket("fake")) + self.assertEqual(Roblox.FetchServers("123", "fake"), []) + self.assertEqual(Roblox.ResolveVipLink("https://www.roblox.com/share?code=abc&type=Server", "fake"), (None, None)) + self.assertGreaterEqual(len(Seen), 4) + for Url, Redirects, Timeout in Seen: + self.assertIs(Redirects, False, Url) + self.assertEqual(Timeout, Roblox.Timeout, Url) + self.assertRegex(Url, r"^https://[a-z]+\.roblox\.com/", Url) + with open(Roblox.__file__, encoding="utf-8") as File: # and no new call forgets it + Source = File.read() + self.assertEqual(Source.count("requests.get(") + Source.count("requests.post("), Source.count("**NoRedirect)")) + + def test_CookieDomainAndValueChecks(self): + for Domain in ("", None, "roblox.com", ".roblox.com", "www.roblox.com", ".ROBLOX.com", "auth.roblox.com"): + self.assertTrue(Roblox.IsRobloxCookieDomain(Domain), Domain) + for Domain in ("evil.example", "roblox.com.evil.example", "evilroblox.com", "roblox.co", 5, ["roblox.com"]): + self.assertFalse(Roblox.IsRobloxCookieDomain(Domain), Domain) + self.assertTrue(Roblox.IsCookieValue("_|WARNING:-DO-NOT-SHARE-THIS.--x|_ABCDEF0123")) + for Bad in ("", None, 5, "a b", "a;b=c", "a\r\nX-Evil: 1", "a\x00", "caf\u00e9", "a" * 8193): + self.assertFalse(Roblox.IsCookieValue(Bad), repr(Bad)[:20]) + + def test_PickServerSurvivesAnOddPing(self): + # 1.2.1: a ping that isn't a number used to raise TypeError inside the sort and fail the whole launch. + Odd = [{"id": "a" * 8 + JobA[8:], "playing": 1, "maxPlayers": 10, "ping": "fast"}, + {"id": "b" * 8 + JobA[8:], "playing": 2, "maxPlayers": 10, "ping": None}, + {"id": "c" * 8 + JobA[8:], "playing": 3, "maxPlayers": 10, "ping": 30}] + self.assertEqual(Roblox.PickServer(Odd, "any", "lowest")["id"][:1], "c") + self.assertEqual(Roblox.PickServer(Odd, "any", "highest")["id"][:1], "c") + def test_FishstrapLauncher(self): self.assertEqual(Storage.Launchers, ("Roblox", "Bloxstrap", "Fishstrap")) Root = tempfile.mkdtemp(prefix="RammitAppData-") @@ -422,6 +463,17 @@ def test_SpinnerColoursMatchSwatch(self): self.assertTrue(any("Accent" in W for W in Themes.ThemeWarnings("SwSpinner"))) +class TestThemeColours(unittest.TestCase): + def test_OddColoursNeverRaise(self): + # 1.2.1: "hsl(1.2.3, 5%, 5%)" passes the swatch pattern but isn't a number; float() raised ValueError while + # the window colour was worked out, so one line in a theme's Style.css stopped RAMMIT from starting. + for Odd in ("hsl(1.2.3, 5%, 5%)", "hsl(..., 5%, 5%)", "hsl(1, 5.5.5%, 5%)", "rgb(999,0,0)", "#12", "", None, "nope("): + self.assertIsNone(Themes._ToHex(Odd), Odd) + self.assertEqual(Themes._ToHex("#abc"), "#aabbcc") + self.assertEqual(Themes._ToHex("rgb(10, 20, 30)"), "#0a141e") + self.assertEqual(Themes._ToHex("hsl(0, 100%, 50%)"), "#ff0000") + + class TestThemeVersions(unittest.TestCase): def MakeTheme(self, Name, Meta): TestThemes.MakeTheme(self, Name, ":root { }", Meta) @@ -475,6 +527,33 @@ def test_MismatchServesDarkUntilAllowed(self): class TestLocalServer(unittest.TestCase): + def test_EveryResponseCarriesThePolicy(self): + # 1.2.1: the Content-Security-Policy used to go out with pages only, so an .svg opened as a document could + # run its own script. It is now on every answer: pages, scripts, images and errors. + import http.client + Server = LocalServer.LocalServer(lambda: "Dark").Start() + try: + def Get(Path, Host=None): + Connection = http.client.HTTPConnection("127.0.0.1", Server.Port, timeout=10) + Connection.putrequest("GET", Path, skip_host=True) + Connection.putheader("Host", Host or f"127.0.0.1:{Server.Port}") + Connection.endheaders() + Response = Connection.getresponse() + Response.read() + Connection.close() + return Response.status, dict(Response.getheaders()) + for Path, Status in (("/HTML/Index.html", 200), ("/JS/Main.js", 200), ("/RAMMIT.png", 200), ("/nope.svg", 404)): + Got, Headers = Get(Path) + self.assertEqual(Got, Status, Path) + self.assertIn("script-src 'self'", Headers.get("Content-Security-Policy", ""), Path) + self.assertEqual(Headers["X-Content-Type-Options"], "nosniff", Path) + Got, Headers = Get("/HTML/Index.html", Host="evil.example") + self.assertEqual(Got, 403) + self.assertIn("default-src 'none'", Headers.get("Content-Security-Policy", "")) + finally: + Server.Stop() + self.assertTrue(0 < LocalServer._Handler.timeout <= 60) # idle connections are dropped + def test_Resolve(self): Root = os.path.join(Paths.SrcDir, "Dark") Resolve = LocalServer._Handler._Resolve @@ -876,10 +955,38 @@ def test_ResizeWaitsForLetGoWhileWindowIsHeld(self): self.Api.ResizeWindow(716) # not held: straight through Window.resize.assert_called_once_with(int(900 * 0.85), int(716 * 0.85)) + @staticmethod + def Jar(Value, Domain=None, Name=".ROBLOSECURITY"): + """One cookie the way pywebview hands it over: a SimpleCookie whose morsel carries the domain.""" + from http.cookies import SimpleCookie + Cookie = SimpleCookie() + Cookie[Name] = Value + if Domain is not None: + Cookie[Name]["domain"] = Domain + return Cookie + def test_FindLoginCookie(self): - Morsel = mock.Mock(value="tok") - self.assertEqual(ApiModule.Api._FindLoginCookie([{"other": mock.Mock(value="x"), ".ROBLOSECURITY": Morsel}]), "tok") - self.assertIsNone(ApiModule.Api._FindLoginCookie([])) + Find = ApiModule.Api._FindLoginCookie + self.assertEqual(Find([self.Jar("x", ".roblox.com", "other"), self.Jar("tok", ".roblox.com")]), "tok") + self.assertEqual(Find([self.Jar("tok", "www.roblox.com")]), "tok") + self.assertEqual(Find([self.Jar("tok")]), "tok") # no domain recorded: taken as before + self.assertIsNone(Find([])) + self.assertIsNone(Find(None)) + + def test_FindLoginCookieIgnoresOtherSites(self): + # 1.2.1: the login window can end up on another site, which could set a cookie with Roblox's name to get + # its own account saved here. Only Roblox's cookie counts, wherever the other one is in the list. + Find = ApiModule.Api._FindLoginCookie + for Domain in ("evil.example", ".notroblox.com", "roblox.com.evil.example", "evilroblox.com", "roblox.co"): + self.assertIsNone(Find([self.Jar("theirs", Domain)]), Domain) + self.assertEqual(Find([self.Jar("theirs", "evil.example"), self.Jar("mine", ".roblox.com")]), "mine") + self.assertIsNone(Find([{".ROBLOSECURITY": mock.Mock(value=None)}])) # nothing usable never raises + + def test_AppInfoCarriesTheCodeName(self): + Info = self.Api.GetAppInfo() + self.assertEqual(Info["CodeName"], Version.AppCodeName) + self.assertTrue(Version.AppCodeName.strip()) + self.assertEqual(Info["Label"], Version.VersionLabel()) # the footer label itself is unchanged def tearDownModule(): diff --git a/Production/RAMMIT-Stable/requirements.txt b/Production/RAMMIT-Stable/requirements.txt index d2768e0..11961da 100644 --- a/Production/RAMMIT-Stable/requirements.txt +++ b/Production/RAMMIT-Stable/requirements.txt @@ -1,4 +1,5 @@ -# Versions RAMMIT 1.2.0 was built and tested with (Python 3.13.14, Windows 11). +# Versions RAMMIT 1.2.0 was built and tested with (Python 3.13.14, Windows 11); unchanged for 1.2.1. +# Checked against published advisories on 2026-11-10 (SECURITY.md > 1.2.1 audit). No hashes yet: see there. # Runtime pywebview==6.2.1 pywin32==312 diff --git a/Web/Website/index.html b/Web/Website/index.html index ae028d2..b991e74 100644 --- a/Web/Website/index.html +++ b/Web/Website/index.html @@ -6,6 +6,10 @@ RAMMIT — One Click. Every Account. + + + @@ -29,7 +33,7 @@ FAQ GitHub - Download v1.1.1 + Download v1.2.1 @@ -50,7 +54,7 @@

one click.
every account.

  • Free
  • Windows 10 / 11
  • -
  • v1.1.1
  • +
  • v1.2.1
  • @@ -313,7 +317,7 @@

    quick answers.

    Download RAMMIT-Setup.exe View on GitHub -

    v1.1.1 · Windows 10 / 11 · zip & checksums

    +

    v1.2.1 · Windows 10 / 11 · zip & checksums