Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check inbound unprocessed packet sizes #46

Open
Joannis opened this issue Oct 19, 2020 · 5 comments
Open

Check inbound unprocessed packet sizes #46

Joannis opened this issue Oct 19, 2020 · 5 comments

Comments

@Joannis
Copy link
Collaborator

Joannis commented Oct 19, 2020

There seem to be SSH-like servers on the internet that behave maliciously, with the intent of repelling malicious connections. They work by sending out an infinite version length or banner. I checked the recent code, but cannot find any length checks or tests. Although I doubt it's a common occurrence, I think it's best to add these checks with tests. I haven't determined a good maximum size yet, however. With some recommendations on that, I'll happily make a PR. I do think separate limits should exist for the pre/post KEX.

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 19, 2020

I do not believe we guard against this, and I believe we should. 1kB is a reasonable default, but we can also make it configurable.

@Joannis
Copy link
Collaborator Author

Joannis commented Oct 21, 2020

@Lukasa 1kb for pre-KEX? I think 1KB is a very low amount POST-KEX.

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 21, 2020

I was proposing we limit only the banner or version, where length prefixes are absent. Once key exchange has happened packet sizes are guarded by other limits.

@Joannis
Copy link
Collaborator Author

Joannis commented Nov 20, 2020

@Lukasa Sorry about the delay, hectic month in terms of freelance projects. In light of the release I visited this issue again, since it's not exactly a big issue to tackel.

As part of the same PR I'd suggest we also implement a maximum limit for packets inside of the parser. If someone sends us a 1GB SSH packet right now, I think NIOSSH would just parse the 1GB size and accumulate the 1GB of data before heading into the next step. And to be honest, I can't seem to find the length checks at all.

@Lukasa
Copy link
Collaborator

Lukasa commented Nov 20, 2020

Yeah, seems reasonable to me. The RFC requires we tolerate at least 2^15 bytes, so we should make sure to meet that requirement.

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

No branches or pull requests

2 participants