Skip to content

FIX MathObfuscationConverter: write the multiplication explicitly for digits - #4055

Merged
Roman Lutz (romanlutz) merged 4 commits into
microsoft:mainfrom
barkha1research-ai:fix-math-obfuscation-digits
Nov 9, 2026
Merged

Roman Lutz (romanlutz) merged 4 commits into
microsoft:mainfrom
barkha1research-ai:fix-math-obfuscation-digits

Conversation

@barkha1research-ai

Copy link
Copy Markdown
Contributor

Description

Fixes #4054.

MathObfuscationConverter writes each character as X = nX - (n - 1)X. For a digit, nX reads as a two-digit number, so 5 = 85 - 75 is 5 = 10, and every digit gives 10 for any n. This writes the multiplication out for decimal digits, for example 5 = 8*5 - 7*5, and leaves letters and symbols unchanged, so existing output for non-digit text is identical. The class docstring now says so.

Tests and Documentation

Added a parametrized test that checks every digit from 0 to 9, and an Arabic-Indic digit, produces a line that matches d = a*d - b*d and is a true identity, plus a test for a prompt that mixes a letter and a digit. The new digit cases fail on main. pytest tests/unit passes apart from one test_attack_analytics case that also fails on main, and ruff, ty and pre-commit pass on the changed files.

… digits

Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 8, 2026 03:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test imports MathObfuscationConverter from its implementation module rather than the public package, violating the public-import check and causing a check-public-imports failure.

1 open issue
What changed in this PR

Fixes #4054 by making decimal-digit equations in MathObfuscationConverter valid arithmetic identities while preserving output for non-digit characters.

Changes:

  • Uses explicit multiplication for decimal digits and documents the behavior.
  • Adds regression tests for ASCII digits, an Arabic-Indic digit, and mixed letter/digit input.
File Description
tests/​unit/​converter/​test_math_obfuscation_converter.py Adds digit identity and mixed-input tests; changes the converter import.
pyrit/​converter/​math_obfuscation_converter.py Adds explicit multiplication for decimal digits and updates the class docstring.

Review effort: Balanced

Signed-off-by: Barkha <340367068+barkha1research-ai@users.noreply.github.com>
…ions get explicit multiplication

Signed-off-by: barkha1research-ai <340367068+barkha1research-ai@users.noreply.github.com>
@barkha1research-ai
barkha1research-ai force-pushed the fix-math-obfuscation-digits branch from 19b497e to aa6c689 Compare November 8, 2026 16:10
@romanlutz Roman Lutz (romanlutz) self-assigned this Nov 8, 2026
@romanlutz
Roman Lutz (romanlutz) merged commit 9a2cf90 into microsoft:main Nov 9, 2026
59 checks passed
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.

BUG MathObfuscationConverter writes false equations for digits ("5 = 85 - 75")

4 participants