[security] Hover over punctuation executes the first expression in the file (document.getText(undefined) → whole document → eval in globalenv)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- r, typescript, vscode
Rechercherichtung
Start with the hover-provider logic in dist/extension.js and the sess::handle_hover() path described in the report. Reproduce the issue using test.R with rm(list = ls()) and hover over punctuation, then verify that punctuation no longer sends the whole document for evaluation and that multi-expression input is rejected defensively.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Environment: vscode-R 3.0.1, sess 3.0.1, R 4.6.1, radian, Linux (remote).
Summary: Hovering the mouse over any punctuation character in an .R file sends the entire document to sess::handle_hover, which evaluates its first top-level expression in the global environment. For the very common file header rm(list = ls()), this silently deletes the user's whole workspace with no console output.
Cause: In the sess hover provider (dist/extension.js):
let r = t.getWordRangeAtPosition(n); const a = /([a-zA-Z0-9._$@ ])+(?<![@$])/; r = t.getWordRangeAtPosition(n, a)?.with({ end: r?.end }); let s = t.getText(r); // r may be undefined -> returns whole document await Zi({ method: "hover", params: { expr: s } });
The regex character class [a-zA-Z0-9._$@ ] does not match #, ", (, ,, |, =, etc. When it fails, r is undefined and document.getText(undefined) returns the full document per the VS Code API.
sess::handle_hover() then does:
expr <- parse(text = expr_str, keep.source = FALSE)[[1]] obj <- eval(expr, .GlobalEnv)
so the first parsed expression of the file is executed. This is arbitrary code execution triggered by mouse movement — unlink(), dbExecute(), system() etc. would run just as readily.
Repro:
Create test.R starting with rm(list = ls()).
In R: a <- 1; b <- 2.
Hover over the # of any comment (not over a word).
ls() → character(0).
Suggested fix: bail out when the range is undefined, and defensively reject multi-expression input in handle_hover/handle_complete:
if (!r) return null;
Note: hovering over letters behaves correctly, which is why this is easy to miss.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.2k
- Forks
- 139
- Ø Merge
- 19 Std. 50 Min.
- Gemergte PRs (30 T.)
- 27
Entwicklungsumgebung
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus REditorSupport/vscode-R
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
REditorSupport/vscode-R#1785 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
REditorSupport/vscode-R#1687 · 4 Kommentare · 3 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
REditorSupport/vscode-R#1799 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
REditorSupport/vscode-R#1791 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Rewrite issue templatesEvtl. vergeben @eitsupi hat das vor 3 Tagen übernommen. Offen
REditorSupport/vscode-R#1783 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in REditorSupport/vscode-R
Ähnliche Issues
-
refactor
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 5 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
OHDSI/Data2Evidence#3450 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
e2e-failure ready-to-code
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
redhat-developer/rhdh-plugin-export-overlays#4011 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
automation missing-model model-sync provider:ofox
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
anomalyco/models.dev#8421 ·
Maintainer antworten meist innerhalb von 1 Tag
-
SlackAdapter and TelegramAdapter are not assignable to Adapter under exactOptionalPropertyTypesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag