-
Notifications
You must be signed in to change notification settings - Fork 40
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
HTTP/2 rapid reset mitigation #344
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f775b81
parent 38aa25e7c20232a4226c4ea5767813b99bca870a
pjfanning d6ab487
remove imports
pjfanning 7d7ffae
Update http2-rapid-reset-configs.backwards.excludes
pjfanning 2d7f0a1
don't throttle header frames
pjfanning e0c6e12
only throttle reset frames
pjfanning 9f55d7c
rename params
pjfanning 88a2c1e
Update Http2ServerDisableResetSpec.scala
pjfanning 8cac7d9
Rapid reset bench (#2)
pjfanning a58637a
disable throttle by default
pjfanning b3fcafb
rename methods
pjfanning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...c/main/mima-filters/1.0.x.backwards.excludes/http2-rapid-reset-configs.backwards.excludes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# New configs added to support throttling HTTP/2 reset frames | ||
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.Http2ServerSettings.resetFrameThrottleCost") | ||
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.Http2ServerSettings.resetFrameThrottleBurst") | ||
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.Http2ServerSettings.resetFrameThrottleInterval") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...t/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDisableResetThrottleSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* license agreements; and to You under the Apache License, version 2.0: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* This file is part of the Apache Pekko project, which was derived from Akka. | ||
*/ | ||
|
||
/* | ||
* Copyright (C) 2018-2022 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package org.apache.pekko.http.impl.engine.http2 | ||
|
||
import org.apache.pekko | ||
import pekko.http.impl.engine.http2.Http2Protocol.FrameType | ||
import pekko.http.impl.engine.http2.framing.FrameRenderer | ||
import pekko.util.ByteStringBuilder | ||
|
||
import java.nio.ByteOrder | ||
|
||
/** | ||
* This tests the http2 server throttle support for rapid resets is disabled by default. | ||
*/ | ||
class Http2ServerDisableResetThrottleSpec extends Http2SpecWithMaterializer(""" | ||
pekko.http.server.remote-address-header = on | ||
pekko.http.server.http2.log-frames = on | ||
""") { | ||
override def failOnSevereMessages: Boolean = true | ||
|
||
"The Http/2 server implementation" should { | ||
"not cancel connection during rapid reset attack (throttle disabled)".inAssertAllStagesStopped( | ||
new TestSetup with RequestResponseProbes { | ||
implicit val bigEndian: ByteOrder = ByteOrder.BIG_ENDIAN | ||
val bb = new ByteStringBuilder | ||
bb.putInt(0) | ||
val rstFrame = FrameRenderer.renderFrame(FrameType.RST_STREAM, ByteFlag.Zero, 1, bb.result()) | ||
val longFrame = Seq.fill(1000)(rstFrame).reduce(_ ++ _) | ||
network.sendBytes(longFrame) | ||
}) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...st/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerEnableResetThrottleSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* license agreements; and to You under the Apache License, version 2.0: | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* This file is part of the Apache Pekko project, which was derived from Akka. | ||
*/ | ||
|
||
/* | ||
* Copyright (C) 2018-2022 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package org.apache.pekko.http.impl.engine.http2 | ||
|
||
import org.apache.pekko | ||
import pekko.http.impl.engine.http2.Http2Protocol.FrameType | ||
import pekko.http.impl.engine.http2.framing.FrameRenderer | ||
import pekko.util.ByteStringBuilder | ||
|
||
import java.nio.ByteOrder | ||
|
||
/** | ||
* This tests the http2 server throttle support for rapid resets. | ||
*/ | ||
class Http2ServerEnableResetThrottleSpec extends Http2SpecWithMaterializer(""" | ||
pekko.http.server.remote-address-header = on | ||
pekko.http.server.http2.log-frames = on | ||
pekko.http.server.http2.reset-frame.throttle-interval = 1s | ||
""") { | ||
override val expectSevereLogsOnlyToMatch: Option[String] = Some( | ||
"HTTP2 connection failed with error [Maximum throttle throughput exceeded.]. Sending INTERNAL_ERROR and closing connection.") | ||
|
||
"The Http/2 server implementation" should { | ||
"cancel connection during rapid reset attack".inAssertAllStagesStopped(new TestSetup with RequestResponseProbes { | ||
implicit val bigEndian: ByteOrder = ByteOrder.BIG_ENDIAN | ||
val bb = new ByteStringBuilder | ||
bb.putInt(0) | ||
val rstFrame = FrameRenderer.renderFrame(FrameType.RST_STREAM, ByteFlag.Zero, 1, bb.result()) | ||
val longFrame = Seq.fill(1000)(rstFrame).reduce(_ ++ _) | ||
network.sendBytes(longFrame) | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be contantFunc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what
constantFunc
means. Do you mean making this aval
instead of adef
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, make just like the
Keep.left/right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 7156492 the sort of change that you want?