Skip to content

Enforce ICE consent - #894

Merged
Sean-Der merged 1 commit into
pion:mainfrom
sirzooro:ice_consent_checks
Sep 23, 2026
Merged

Sean-Der merged 1 commit into
pion:mainfrom
sirzooro:ice_consent_checks

Conversation

@sirzooro

@sirzooro sirzooro commented Mar 1, 2026 •

Copy link
Copy Markdown
Contributor
Expire consent after 30 seconds without an authenticated successful
Binding response, and fail the selected connection on a matching
STUN 403 response. Allow the Binding Request handler to send an
authenticated error response to revoke consent explicitly.

Reuse existing keepalive requests and preserve disconnect timeouts,
candidate registration, selector interfaces, and role-conflict handling.

@codecov

codecov Bot commented Mar 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.32143% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.75%. Comparing base (ff25299) to head (f916920).

Files with missing lines Patch % Lines
agent.go 96.96% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #894      +/-   ##
==========================================
+ Coverage   91.56%   91.75%   +0.19%     
==========================================
  Files          45       45              
  Lines        5309     5360      +51     
==========================================
+ Hits         4861     4918      +57     
+ Misses        448      442       -6     
Flag Coverage Δ
go 91.75% <97.32%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sirzooro
sirzooro force-pushed the ice_consent_checks branch 2 times, most recently from 07885ec to 1bd665a Compare March 1, 2026 13:03
@sirzooro
sirzooro requested a review from Copilot March 1, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Implements RFC 7675-style consent freshness handling in the ICE agent by tracking consent from existing STUN Binding request/response traffic, enforcing expiry via validateSelectedPair(), and adding support for authenticated inbound STUN Binding Error responses (including 403-driven consent revocation). It also introduces an application hook to emit custom authenticated Binding Error responses for inbound Binding Requests.

Changes:

  • Add consent freshness state (consentFreshnessTimeout, lastConsentAt), default timeout configuration, and expiry enforcement.
  • Add inbound Binding Error response handling (MESSAGE-INTEGRITY + transaction/destination matching) and 403 consent revocation behavior.
  • Add BindingRequestErrorResponseHandler and sendBindingError(...) to allow custom authenticated Binding Error responses (with optional extra STUN attributes).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
selection_test.go Adds tests validating selector behavior when BindingRequestErrorResponseHandler returns a custom Binding Error response.
selection.go Evaluates the new error-response handler before pair creation and sends Binding Error responses when requested; renames pending-success helper usage.
gather_test.go Updates DTLS relay test to use the new DTLS options-style listener API.
gather.go Updates DTLS TURN client creation to the options-style DTLS client API.
agent_test.go Adds tests for authenticated inbound 403 error response consent revocation and consent-expiry validation.
agent_options_test.go Adds coverage for WithConsentFreshnessTimeout and WithBindingRequestErrorResponseHandler.
agent_options.go Introduces WithConsentFreshnessTimeout and WithBindingRequestErrorResponseHandler options.
agent_config_test.go Verifies default consent freshness timeout and that a zero timeout disables expiry.
agent_config.go Adds default consent timeout constant, config fields, and initializes consentFreshnessTimeout.
agent.go Implements consent timestamping/expiry logic, Binding Error sending, and inbound Binding Error response handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread agent.go Outdated
Comment thread agent.go Outdated
Comment thread agent.go Outdated
Comment thread agent.go Outdated
Comment thread agent.go Outdated
Comment thread gather.go Outdated
@sirzooro
sirzooro force-pushed the ice_consent_checks branch 2 times, most recently from 5bbcc74 to 6ba75e1 Compare March 1, 2026 18:56
@JoTurk
JoTurk self-requested a review April 9, 2026 02:11
@Sean-Der
Sean-Der force-pushed the ice_consent_checks branch 5 times, most recently from eb5ec10 to 1028e34 Compare September 22, 2026 00:04
@Sean-Der Sean-Der changed the title Add RFC 7675 Consent Freshness checks Enforce ICE consent Sep 22, 2026
@Sean-Der
Sean-Der force-pushed the ice_consent_checks branch 4 times, most recently from 3719c35 to 22b234b Compare September 22, 2026 16:10
Comment thread agent.go
return best
}

func (a *Agent) getPairForWrite() (*CandidatePair, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moved logic out of transport.go but this isn't new

@Sean-Der

Copy link
Copy Markdown
Member

I switched back to sending Binding Requests every 2 seconds.

Old ice-lite Pion instances would go to disconnected because of this. We can address this in a future smaller away, but wanted to land the larger consent change first.

@Sean-Der
Sean-Der force-pushed the ice_consent_checks branch 2 times, most recently from 27e7cdf to 66407dc Compare September 22, 2026 16:33

@JoTurk JoTurk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is good,

Minor detail we allow agents to disable keepalive and we use it in many tests, some of them are introduced in this pr and recently #988 (review)

So this behavior is documented, but now we use the same timer for consent freshness, and with keepalive = 0, the connection will fail after the failed timeout (30s), I'm not sure how common keepalive=0 is but this sounds like something someone would set while debugging or optimizing I found a similar bug when i was testing the disconnection bug #951 Maybe we should fix or prevent this?

@Sean-Der
Sean-Der force-pushed the ice_consent_checks branch 2 times, most recently from 1e60433 to 3a200d6 Compare September 22, 2026 23:58
Expire consent after 30 seconds without an authenticated successful
Binding response, and revoke consent on a matching authenticated STUN
403 response. Reject application-data writes on expired or revoked
pairs while allowing other pairs with fresh consent to remain usable.

Keep consent requests active on the existing connectivity timer when
WithKeepaliveInterval(0) disables extra keepalives. Document that full
ICE agents continue renewing consent at the default cadence.

Cover expiry, revocation, zero keepalive intervals, and pair selection.
Close the peer in timeout tests to simulate lost connectivity.

Validation: the full race-enabled test suite and golangci-lint passed.
@Sean-Der
Sean-Der merged commit 1d3ec03 into pion:main Sep 23, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants