You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix ~360 bugs, security issues and performance problems found in 21 rounds of code review - #1
This PR collects the fixes from 21 rounds of independent code review of TermRest. Each round, seven reviewers read one area each for bugs, security flaws and performance problems:
HTTP and TLS
recording and history
workspace and CLI
collections and YAML
scripting
TUI shell
TUI views
Every finding was triaged before the next round started. Each accepted finding was fixed with a test that fails without the fix, and the whole suite was verified on Windows, Linux and Native AOT. About 360 findings are fixed: roughly 65 security, 30 performance, and the rest bugs.
What a script does stays the user's responsibility, as designed: scripts run in the runtime the user chooses.
Highlights
Security
Files from outside the workspace folder (rounds 20–21):
Requests send body and form-data files only from the workspace folder, also once links are resolved, unless files from outside it are allowed for that folder (Tools › Settings › Outside files, or --allow-outside-files). A cloned collection could otherwise upload any file the user can read, such as SSH keys.
Links are followed as the OS follows them, including an absolute link target with .. after another link.
On Windows, client certificates and the CA bundle on a network share outside the folder aren't opened until then either, and the Body tab doesn't look up paths outside the folder. Looking at \\server\share makes Windows sign in to that server with the user's credentials.
Credentials only go where they belong.
A redirect to another host drops auth headers, API keys, cookies and the client certificate chosen for the original URL.
A Digest or NTLM password is never sent in answer to a Basic challenge.
v3 credential sets are chosen by their URL rules, including in duplicated folders.
A curl command pasted into a request from history becomes a standalone request, without the original request's auth or scripts.
No header injection: header values containing CR, LF or NUL are refused.
Secrets are masked in history and redacted in recordings, reports, errors and the UI in every form a server may echo them back:
URL-escaped and JSON-escaped
UTF-16 and UTF-32, and JSON after a byte order mark
URL user info and proxy passwords
more credential header names, such as X-Auth-Key and Ocp-Apim-Subscription-Key
values that scripts store
cURL export quotes safely. It refuses a request that curl would send differently, or that TermRest itself would not send.
Files:
Saves are atomic, go through symbolic links and keep file permissions, and copies of private files stay private.
A cloned workspace's settings can't silently send requests through a proxy or turn off TLS verification.
Script runtimes are never started from the workspace folder.
Collections and environments
Postman v2.1 JSON and v3 YAML files round-trip unchanged. YAML is read back exactly as it will be written before it is saved, including final line breaks and block scalars at the end of a file.
Hostile files are refused instead of crashing or hanging TermRest: deep nesting, devices, huge files and self-referencing variables.
v3 secrets, credential sets, and collections without a root definition are read as Postman writes them.
The workspace now loads Native Git collections whose requests are all in folders.
convert and validate refuse folders that aren't collections.
A workspace folder that can't be listed, or a link to a collection folder that is gone, is reported as a load error. Before, the workspace failed to open, or the collection disappeared without a word.
Scripts
The Python, JavaScript, C# and PowerShell workers keep a run's output, tests and variable changes when a thrown value can't be described, or when the request the scripts left can't be sent. Previously the whole run failed with "The script runner failed".
Output, memory and run time are bounded, and PowerShell's console capture works across runspaces.
Error headings say whether the scripts didn't run or failed.
In Python, tr.request.headers can be replaced with a dict, any other mapping, or a list of pairs, as with requests.
On Linux and macOS, a C# #:project path is passed by its real path: NuGet drops the projects a project references when the path to it goes through a symbolic link, such as macOS's /var.
HTTP and TLS
TLS details are recorded when the handshake completes and read again after the response. Protocol, cipher and client certificate are therefore correct for servers that close the connection after responding, and for servers that ask for the certificate later through a TLS 1.2 renegotiation.
Content-Type and charset handling is lenient:
a header with a stray ; is kept as received;
legacy code pages are decoded;
UTF-16 without a byte order mark is detected.
TUI
The editor's context follows reloads, deletes, requests opened from history, and Ctrl+N. That context is the inherited auth, scripts, client certificate and body file.
Requests typed outside a collection are consistent scratch requests.
Copy as cURL refuses requests TermRest wouldn't send.
The response view shows at most 1 MB of the body and of script output.
CLI and tests
send, run, history, convert and validate have clearer exit codes and messages.
A new test project, TermRest.Cli.Tests, runs the built termrest as a separate process.
history --show tells a response without a body (204, HEAD) from one whose body wasn't kept.
The suite now has 1026 tests.
Commits
Commit
Content
2314827
Core, CLI and TUI: fixes from 18 rounds of code review
3d2c151
Docs: what 18 rounds of code review settled
ea35bad
Core and TUI: fixes from review round 19
bc8b69c
Docs: review round 19
d0a28a1
Core, CLI and TUI: fixes from review rounds 20 and 21
ede24b0
Docs: review rounds 20 and 21
f8ca53d
Core and CLI: fixes from the Copilot review of this PR
a1444ca
Core: fixes from the second Copilot review of this PR
The fixes span all three layers, so the code is in one commit per review batch, with the README changes in a separate commit. Every commit builds on its own.
Testing
Check
Result
Windows, full suite
1026 tests: 1018 passed, 8 platform skips
Linux, WSL Ubuntu 24.04, full suite
1021 tests: 1011 passed, 10 Windows-only or root skips (run before the one-line YAML key fix and the Copilot review fixes; CI runs them on Ubuntu and macOS, and the new Linux-only tests fail without their fixes in WSL)
New security tests, Linux
The link tests fail with the round-21 fixes reverted and pass with them
Native AOT publish, win-x64
0 warnings, ~20.2 MB
termrest validate over 797 real v3 collections from public repositories
788 pass; the rest are the 7 known invalid sample files and 2 folders that aren't collections
macOS is covered by CI only. The new renegotiation test skips its assertion where the test server can't renegotiate (macOS). The two macOS failures on bc8b69c (a C# #:project build through /var, and a PowerShell memory bound measured on Linux and Windows only) are fixed in d0a28a1.
Notes
Two redaction tests use Stripe's public sample test key. It is written as "sk_test_" + "…" so GitHub push protection doesn't flag it.
The five comments of the two Copilot reviews of this PR are fixed in f8ca53d and a1444ca, each with a test that fails without its fix.
The review loop continues: round 22 is under way. If it finds anything, the fixes will land on this branch as follow-up commits.
Eighteen rounds of independent review, by seven reviewers each round (HTTP, recording, workspace and CLI, collections, scripting, TUI shell, TUI views), looked for bugs, security flaws and performance problems. About 345 findings were fixed, 60 of them security fixes, each with a test that fails without its fix, verified on Windows, Linux and Native AOT. What a script does stays the user's responsibility, as designed.
Security: credentials go only where they belong. Redirects to other hosts drop auth headers, API keys, cookies and the client certificate chosen for the original URL; a Digest or NTLM password is never sent to a Basic challenge; v3 credential sets are chosen by their URL rules (also in a copy of a folder); a curl command pasted into a request from history no longer takes its folder's auth. Header values with CR, LF or NUL are refused. Secrets are masked in the history and redacted in recordings, reports, errors and the UI in the forms a server may echo them (URL- and JSON-escaped, UTF-16 and UTF-32, JSON after a byte order mark, URL user info, proxy passwords, names such as X-Auth-Key or Ocp-Apim-Subscription-Key, values scripts store). Exported curl commands quote what they must and refuse what curl would send differently or TermRest would not send. Files are written atomically, through links, keeping their permissions; copies of private files stay private; a cloned workspace's settings can't silently send requests through its proxy or turn TLS checks off; script runtimes are never started from the workspace folder.
Collections and environments: Postman v2.1 JSON and v3 YAML round-trip unchanged, and YAML is read back as it will be written (final line breaks, block scalars at the end of a file) before it is saved. Hostile files (deep nesting, devices, huge files, self-referencing variables) are refused instead of crashing or hanging. v3 secrets, credential sets and collections without a root definition are read as Postman writes them: the workspace now loads Native Git collections whose requests are all in folders, and convert and validate refuse folders that aren't collections.
Scripts: the Python, JavaScript, C# and PowerShell workers keep a script's output, tests and variable changes when a thrown value can't be described or the request the scripts left can't be sent, instead of failing the whole run. Output, memory and run time are bounded (PowerShell's console writer works across runspaces), and errors say whether the scripts didn't run or failed.
HTTP: TLS details are read when the handshake completes and again after the response, so the protocol, cipher and client certificate are right for servers that close the connection or ask for the certificate later. A Content-Type that .NET's parser rejects (a stray ;) is kept as received, and bodies are decoded from legacy code pages and from UTF-16 without a byte order mark.
TUI: the editor's context (inherited auth, scripts, client certificate, body file) follows reloads, deletes, requests from history and Ctrl+N; a request typed where a deleted one was is a scratch request; Copy as cURL refuses what TermRest wouldn't send; the response's body and script output are shown up to 1 MB.
CLI: clearer exit codes and messages for send, run, history, convert and validate. A new test project, TermRest.Cli.Tests, runs the built termrest as a separate process; the suite has 1009 tests.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
README: how credentials are masked and redacted (history, recordings, reports), where redirects and v3 credential sets send them, and what a curl command pasted into a request from history takes; what curl export refuses; what scripts' output and errors look like, and what happens to a request the scripts leave unusable (Python headers as a dict too); how YAML files keep their final line break; which folders in postman/collections are collections, and what convert and validate accept; how TLS details are read; the Scripts tab's and the response's limits.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A curl command pasted into a request opened from the history no longer keeps that request's description, scripts and script settings: as one imported from the menu, it is a request of its own, and the request's scripts (which could add its credentials) don't run for the host it names. A collection folder in postman/collections that has a folder named postman is opened as that collection when it is given on its own (run, send, import-curl, history, the UI), not as a workspace. Python scripts can replace tr.request.headers with any mapping, such as requests' CaseInsensitiveDict or urllib's headers, as well as with a dict or pairs. The test server echoes without a client certificate where Kestrel can't renegotiate (macOS), so the round-18 renegotiation test passes on the macOS CI job.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
README: a curl command pasted into a request from the history takes neither the auth nor the scripts of that request or its folders; Python's tr.request.headers can be replaced with any mapping.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Requests send body and form-data files only from the workspace folder, also once links are resolved, unless files from outside it are allowed for that folder (Tools › Settings › Outside files, kept in the user's settings; or --allow-outside-files on send, run and certs list): a cloned collection could otherwise upload any file the user can read. Links are followed as the OS follows them, so an absolute link target with a .. after another link (/proc/self/cwd/d/../.ssh/id_rsa) no longer passes as text. On Windows, client certificates and the CA bundle on a network share outside the folder are not opened until then either, and the Body tab no longer looks up a path outside the folder, nor any file outside File mode: looking at \\server\share makes Windows sign in to that server with the user's credentials.
A folder of the workspace that can't be listed, and a link in postman/collections (or postman/collections, environments or globals themselves) to something that is gone, are now load errors; before, the workspace failed to open, or the collection vanished without a word. On Linux and macOS, a C# #:project path is passed by its real path, as NuGet drops the projects a project references when the path to it goes through a symbolic link (macOS's /var); with a PowerShell output-memory bound measured on macOS, this fixes the macOS CI job. A curl command pasted into a request from the history while it is on its way detaches that send and clears the response pane. history --show tells a response without a body (204, HEAD) from one whose body isn't kept. YAML keys that hold " *" are written double-quoted, as YamlDotNet reads them as text. The CLI tests' server reads a request's body before it answers.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
README: files from outside the workspace folder (body and form-data files; on Windows, certificates and the CA bundle on network shares) are used only once allowed for that folder, in Tools › Settings › Outside files or with --allow-outside-files (send, run, certs list), and the Body tab doesn't look such paths up; folders that can't be listed and links to folders that are gone are load errors; YAML keys that hold " *" are written double-quoted.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ShikeChen-MS
changed the title
Fix ~350 bugs, security issues and performance problems found in 19 rounds of code review
Fix ~360 bugs, security issues and performance problems found in 21 rounds of code review
Nov 14, 2026
This PR hardens TermRest’s Core, CLI, and terminal UI through fixes collected across 19 review rounds, with regression coverage for security, data preservation, and performance.
Changes:
Strengthens credential handling, redaction, runtime selection, and workspace permissions.
Improves collection round-tripping, save-conflict detection, CLI diagnostics, and UI behavior.
Adds CLI integration infrastructure and expands Core and TUI regression tests.
send, run, convert and validate tell files of a v3 collection that could not be read from the note about non-HTTP requests that are not shown by a flag the collection sets as it loads (HasUnreadableFiles), not by the text of its warnings: a file or folder that could not be read and whose name holds "non-HTTP" was taken for that note, so the commands succeeded without it and convert wrote the collection without it. Names added to recordingRedact win over the names known not to be credentials (Access-Control-Allow-Credentials). A PowerShell curl.exe command whose double-quoted value ends in a backslash ("C:\temp\") is read as PowerShell when a backtick ends one of its lines: in PowerShell's "…" only the backtick escapes, and the other shells' reading took the value for one that went on past it, so the URL became part of the body.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Environment saves can create world-readable copies containing secrets, while same-size, timestamp-preserving external edits can be silently overwritten without conflict detection.
For a collection with no root definition or root-level request, an unreadable child directory can make discovery classify the whole collection as absent, silently hiding its readable requests too. Propagate the discovery error so MayBeCollection retains the candidate and loading reports the inaccessible path instead of omitting the collection.
Saving never overwrites a file whose content another program changed, also when the new content has the same length and the file kept its time (a copy made with cp -p or rsync -t, a file from an archive): the content's hash is compared whenever the length matches, not only when the time differs. An environment saved under another path is as private as the file it was read from also when the paths differ only in case, which on Linux is another file: there it was written with the default permissions (0644 with a 022 umask).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Workspace permission matching conflates case-distinct paths on case-sensitive macOS volumes, allowing upload and proxy permissions to apply to another workspace without consent.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Use case-sensitive workspace matching on case-sensitive macOS volumes
On a case-sensitive macOS volume, SameFolder treats distinct workspaces such as /work/API and /work/api as identical, so allowing outside files for one also authorizes uploads from the other without consent. The proxy-consent lookup at UserSettings.cs:134 has the same issue. Use conservative ordinal matching on macOS (or filesystem-aware identity) consistently for granting, checking and revoking permissions, and add case-distinct workspace tests.
Detect cmd.exe continuations when apostrophes appear in commands
src/TermRest.Core/Import/ShellWords.cs:105
Apostrophes are ordinary characters in cmd.exe, so this scan hides the caret continuation in curl https://example.com --data foo'bar ^ followed by a newline and -H X-Test:ok. Detection falls back to POSIX parsing, which absorbs the header into the unterminated body string. Account for cmd.exe's quoting rules when detecting continuations and add this regression case to CurlImporterTests.
Propagate unreadable nested-folder errors during collection discovery
src/TermRest.Core/Postman/V3/V3Names.cs:98
For a definition-less Native Git collection whose requests are all in an unreadable child folder, this catch turns the access failure into false, so workspace discovery silently omits the collection. Let these I/O and access errors propagate to MayBeCollection, which retains candidates whose contents could not be checked so loading can report the failure. Add a regression case for an unreadable nested folder.
MIT license, app icon, and fixes from the last Copilot review of #1
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
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.
Summary
This PR collects the fixes from 21 rounds of independent code review of TermRest. Each round, seven reviewers read one area each for bugs, security flaws and performance problems:
Every finding was triaged before the next round started. Each accepted finding was fixed with a test that fails without the fix, and the whole suite was verified on Windows, Linux and Native AOT. About 360 findings are fixed: roughly 65 security, 30 performance, and the rest bugs.
What a script does stays the user's responsibility, as designed: scripts run in the runtime the user chooses.
Highlights
Security
--allow-outside-files). A cloned collection could otherwise upload any file the user can read, such as SSH keys...after another link.\\server\sharemakes Windows sign in to that server with the user's credentials.X-Auth-KeyandOcp-Apim-Subscription-KeyCollections and environments
convertandvalidaterefuse folders that aren't collections.Scripts
tr.request.headerscan be replaced with a dict, any other mapping, or a list of pairs, as withrequests.#:projectpath is passed by its real path: NuGet drops the projects a project references when the path to it goes through a symbolic link, such as macOS's/var.HTTP and TLS
;is kept as received;TUI
CLI and tests
send,run,history,convertandvalidatehave clearer exit codes and messages.TermRest.Cli.Tests, runs the builttermrestas a separate process.history --showtells a response without a body (204, HEAD) from one whose body wasn't kept.Commits
23148273d2c151ea35badbc8b69cd0a28a1ede24b0f8ca53da1444caThe fixes span all three layers, so the code is in one commit per review batch, with the README changes in a separate commit. Every commit builds on its own.
Testing
termrest validateover 797 real v3 collections from public repositoriesmacOS is covered by CI only. The new renegotiation test skips its assertion where the test server can't renegotiate (macOS). The two macOS failures on
bc8b69c(a C##:projectbuild through/var, and a PowerShell memory bound measured on Linux and Windows only) are fixed ind0a28a1.Notes
"sk_test_" + "…"so GitHub push protection doesn't flag it.f8ca53danda1444ca, each with a test that fails without its fix.