Skip to content

Preserve server TLS request flags when TLS is disabled (prevent fail-open) - #313

Draft
rgerhards wants to merge 2 commits into
masterfrom
codex/propose-fix-for-tls-request-issue
Draft

Preserve server TLS request flags when TLS is disabled (prevent fail-open)#313
rgerhards wants to merge 2 commits into
masterfrom
codex/propose-fix-for-tls-request-issue

Conversation

@rgerhards

@rgerhards rgerhards commented Aug 20, 2026

Copy link
Copy Markdown
Member

Motivation

  • Fix a fail-open downgrade where calling the newer TLS-enable APIs could return RELP_RET_ERR_NO_TLS but not record that TLS was requested, allowing relpSrvRun() to skip TLS setup and start a plaintext listener when librelp is built without TLS.

Description

  • Update relpSrvEnableTLS2 and relpSrvEnableTLSZip2 to set pThis->bEnableTLS / pThis->bEnableTLSZip unconditionally and still return RELP_RET_ERR_NO_TLS in builds without TLS using a #if !(defined(ENABLE_TLS) || defined(ENABLE_TLS_OPENSSL)) guard for the error path.

Testing

  • Ran git diff --check which reported no whitespace or diff errors; this succeeded.
  • Ran autoreconf -fvi which failed in the current environment because aclocal is not available, so full autotools regeneration could not be executed here.

Codex Task


Summary by cubic

Prevents a fail-open downgrade when enabling server TLS on builds without TLS. Previously relpSrvEnableTLS2/relpSrvEnableTLSZip2 returned RELP_RET_ERR_NO_TLS but did not record the TLS request, so relpSrvRun() started a plaintext listener; now the enable calls always set the request flags and relpSrvRun() returns RELP_RET_ERR_NO_TLS without starting a listener.

  • Always set bEnableTLS/bEnableTLSZip in relpSrvEnableTLS2/relpSrvEnableTLSZip2; still return RELP_RET_ERR_NO_TLS when TLS is unsupported; add RELPOBJ_assert(pThis, Srv) to validate input.
  • No behavior change in TLS-enabled builds. In non-TLS builds callers still receive RELP_RET_ERR_NO_TLS and must not start a listener.
  • Adds regression test tls-request-no-tls (built and run only when !ENABLE_TLS_GENERIC) to verify flags are set and no TCP listener is created.

Written for commit 1ca58dc. Summary will update on new commits.

Review in cubic

@rgerhards rgerhards self-assigned this Aug 20, 2026
@rgerhards rgerhards added this to the 1.14 milestone Aug 20, 2026
@rgerhards
rgerhards requested a lite review from Copilot August 20, 2026 15:36

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

Prevents a TLS “fail-open” downgrade in non-TLS builds by recording that TLS (and TLS+ZIP) was requested even when the TLS enable APIs return RELP_RET_ERR_NO_TLS, so relpSrvRun() won’t silently start a plaintext listener.

Changes:

  • Set relpSrv_t::bEnableTLS unconditionally in relpSrvEnableTLS2(), while still returning RELP_RET_ERR_NO_TLS in non-TLS builds.
  • Set relpSrv_t::bEnableTLSZip unconditionally in relpSrvEnableTLSZip2(), while still returning RELP_RET_ERR_NO_TLS in non-TLS builds.
Suppressed comments (1)

src/relpsrv.c:369

  • relpSrvEnableTLSZip2() now dereferences pThis unconditionally (even in non-TLS builds), but it doesn’t validate the server handle (contrast with most other relpSrv* setters which use RELPOBJ_assert(pThis, Srv)). Adding the assertion keeps the API consistent and catches invalid handles in debug builds. Also update the #endif comment to match the new #if !(...) guard.
	ENTER_RELPFUNC;
	pThis->bEnableTLSZip = 1;
#if !(defined(ENABLE_TLS) || defined(ENABLE_TLS_OPENSSL))
	iRet = RELP_RET_ERR_NO_TLS;
#endif /* #ifdef ENABLE_TLS | ENABLE_TLS_OPENSSL */

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/relpsrv.c Outdated
Comment on lines 355 to 359
ENTER_RELPFUNC;
#if defined(ENABLE_TLS) || defined(ENABLE_TLS_OPENSSL)
pThis->bEnableTLS = 1;
#else
#if !(defined(ENABLE_TLS) || defined(ENABLE_TLS_OPENSSL))
iRet = RELP_RET_ERR_NO_TLS;
#endif /* #ifdef ENABLE_TLS | ENABLE_TLS_OPENSSL */
@rgerhards
rgerhards force-pushed the codex/propose-fix-for-tls-request-issue branch from 8683114 to b052140 Compare August 20, 2026 16:26
@rgerhards
rgerhards force-pushed the codex/propose-fix-for-tls-request-issue branch from b052140 to 1ca58dc Compare August 20, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants