Skip to content

Fix read-only bypass via Cut/Delete context menu commands (Issue #444)#450

Open
JyslaFancy wants to merge 1 commit into
icsharpcode:masterfrom
JyslaFancy:fix/issue-444-cut-enabled-when-readonly
Open

Fix read-only bypass via Cut/Delete context menu commands (Issue #444)#450
JyslaFancy wants to merge 1 commit into
icsharpcode:masterfrom
JyslaFancy:fix/issue-444-cut-enabled-when-readonly

Conversation

@JyslaFancy

Copy link
Copy Markdown

Description

Fixes #444: Cut and Delete commands remain enabled in context menu when IsReadOnly=true.

Vulnerability

When , the Cut and Delete commands remained enabled in the context menu and via keyboard shortcuts (Ctrl+X, Del). This allowed bypassing the read-only protection — a user could delete or move content from a read-only document.

Root Cause

The handlers for Cut () and Delete () only checked whether text was selected. They never verified that the document was writable via .

Fix

  • CanCutOrCopy: Now checks when the command is . Copy (which also uses ) remains unaffected — copying from read-only documents is legitimate.
  • CanDelete: Now requires in addition to having a non-empty selection.
  • CanPaste: Already correctly validated via — no changes needed.

Attack Vector

Context menu or keyboard shortcut (Ctrl+X, Del) on a read-only with selected text.

…arpcode#444)

VULNERABILITY: When TextEditor.IsReadOnly=true, the Cut and Delete
commands remained enabled in the context menu and via keyboard
shortcuts. This allowed an attacker with UI access to delete or
move content from a read-only document, bypassing the read-only
protection.

ROOT CAUSE: The CanExecute handlers for Cut (CanCutOrCopy) and
Delete (CanDelete) only checked whether text was selected, never
verified that the document was writable via
ReadOnlySectionProvider.CanInsert().

FIX:
- CanCutOrCopy: Now checks ReadOnlySectionProvider.CanInsert()
  when the command is ApplicationCommands.Cut. Copy (also using
  CanCutOrCopy) remains unaffected — copying from read-only
  documents is legitimate.
- CanDelete: Now requires ReadOnlySectionProvider.CanInsert() in
  addition to having a non-empty selection.
- CanPaste: Already validated via CanInsert — no changes needed.

Attack vector: Context menu or keyboard shortcut (Ctrl+X, Del)
on a read-only TextEditor with selected text.
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.

Context menu ApplicationCommands.Cut still enabled when IsReadOnly = true

1 participant