Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134873: Fix a DOS issue in idlelib#134874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
johnzhou721 wants to merge20 commits intopython:main
base:main
Choose a base branch
Loading
fromjohnzhou721:idledos

Conversation

johnzhou721
Copy link
Contributor

@johnzhou721johnzhou721 commentedMay 29, 2025
edited by bedevere-appbot
Loading

A DOS by Quadratic complexity issue is fixed in idlelib. Part of (but does not fix)#134873.

@terryjreedyterryjreedy moved this toIn Progress inIDLE IssuesMay 29, 2025
@terryjreedyterryjreedy self-assigned thisMay 29, 2025
@terryjreedy
Copy link
Member

I believe that the 6 lines from 1205 to 1210 can be replaced by 2 lines -- an re.match and an f-string. I will submit an alternate proposal later. I believe that the inputvevent name should have either no <>s or 2 of each, with maybe the latter for back compatibility (I will test). But I will may stick with the more general code to not break buggy extensions.

Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

Assuming this is the fix that we go with, let's add a test case.

@ZeroIntensityZeroIntensity added type-securityA security issue needs backport to 3.9only security fixes needs backport to 3.10only security fixes needs backport to 3.11only security fixes needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsMay 29, 2025
@johnzhou721
Copy link
ContributorAuthor

johnzhou721 commentedMay 29, 2025 via email

@terryjreedy so should I leave the code for now, or should I go aheadand replace with the re.match thing you are going to propose?@ZeroIntensity so do you mean that active voice is preferred inrelease notes? I can replace this specific case with the change thatyou are suggesting, but I'm asking for advice in this aspect forfuture News.

@johnzhou721
Copy link
ContributorAuthor

johnzhou721 commentedMay 29, 2025 via email

Yes, I think it can be. Will fix.
Message ID: ***@***.***>

@kexinoh
Copy link

@johnzhou721
I would greatly appreciate it if you could kindly address the issue located at

whileTrue:
chars=chars[:-1]
ncharsdeleted=ncharsdeleted+1
have=len(chars.expandtabs(tabwidth))
ifhave<=wantorchars[-1]notin"\t":
break
. I sincerely apologize for overlooking this in my previous message.

As an example, I successfully utilized Gemini 2.5 Pro to generate a reasonable fix for this problem. Could you give it a try?

@johnzhou721
Copy link
ContributorAuthor

@kexinoh Yes, I would give it a try once I have time; however, I am working on something else right now -- is it acceptable if I delay this by about a day or so?

(if anyone else has a fix ready before I get to this, feel free to make a pr onto the branch of my pr and I'll merge it into my PR)

…dziqkQ.rstCo-authored-by: Peter Bierma <zintensitydev@gmail.com>
@johnzhou721
Copy link
ContributorAuthor

@kexinoh I have a small amount of time not enough to work on anything else before I end my day so I attempted the issue you pointed out -- but can't test though.

@johnzhou721
Copy link
ContributorAuthor

Assuming this is the fix that we go with, let's add a test case.

Where? How? For what? Thanks!@ZeroIntensity

@ZeroIntensity
Copy link
Member

Where? How? For what?

We need a test case intest_idlelib that results in DOS/extreme slowness off main. Basically, just do something to prove that this PR fixes it (probably just testing with large amounts of data).

@johnzhou721
Copy link
ContributorAuthor

I've added tests but there are still logic errors.

@johnzhou721
Copy link
ContributorAuthor

Good. Very good.

I've found that I've been assuming everything has width of tabwidth... I'd need to change my approach significantly.

@johnzhou721
Copy link
ContributorAuthor

OK So I've just made the tests run in an more organized way, and I've also asserted an at least 10x speedup (w/ one of the test of 10^4 order of magnitude length) and I've also used the old code to confirm the test data is correct. Looks good to me so far!

@johnzhou721
Copy link
ContributorAuthor

Wait... all platforms are failing EXCEPT the one I have access to...

@johnzhou721

This comment was marked as resolved.

@johnzhou721
Copy link
ContributorAuthor

Never mind...

@johnzhou721
Copy link
ContributorAuthor

I've fixed the issues -- is macOS 14 not using --slow-ci?

Anyways, I just scrubbed the ncharsdeleted stuff in the function and calculate it manually using length differences.

@bedevere-bot I have made the requested changes, please review again

@johnzhou721
Copy link
ContributorAuthor

I have made the requested changes; please review again

@bedevere-app
Copy link

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

@bedevere-appbedevere-appbot requested a review frompicnixzJune 1, 2025 23:34
@picnixzpicnixz dismissed theirstale reviewJune 1, 2025 23:35

Changes were made, but I'll review it tomorrow (or later this week, I'll be offline for a few days).

@picnixzpicnixz removed their request for reviewJune 2, 2025 09:47
@picnixz
Copy link
Member

(I'm removing the request until I have time)

johnzhou721 reacted with rocket emoji

@zware
Copy link
Member

Sidenote: I have a very hard time believing that there is any reasonable DOS in this code at all. Can someone please explain how it can be exploited?

@johnzhou721
Copy link
ContributorAuthor

@zware Maybe have a huge indentwidth and carefully configured string of whitespaces so that want gets very small?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@picnixzpicnixzpicnixz left review comments

@terryjreedyterryjreedyAwaiting requested review from terryjreedyterryjreedy is a code owner

@zwarezwareAwaiting requested review from zware

@ZeroIntensityZeroIntensityAwaiting requested review from ZeroIntensity

Assignees

@terryjreedyterryjreedy

Labels
awaiting reviewneeds backport to 3.9only security fixesneeds backport to 3.10only security fixesneeds backport to 3.11only security fixesneeds backport to 3.12only security fixesneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixestype-securityA security issue
Projects
Status: In Progress
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@johnzhou721@terryjreedy@kexinoh@ZeroIntensity@picnixz@zware

[8]ページ先頭

©2009-2025 Movatter.jp