Repository navigation
fix(connections): sign RDS IAM tokens for the database endpoint, not the local forward - #1953
Conversation
…the local forward
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 339788cb63
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let schemeRange = text.range(of: "://") { | ||
| text = String(text[schemeRange.upperBound...]) | ||
| } | ||
| if let slashIndex = text.firstIndex(of: "/") { | ||
| text = String(text[..<slashIndex]) |
There was a problem hiding this comment.
Parse pasted URLs by authority
When the override is a valid connection URL containing user information, such as postgresql://[email protected]:5432/db, removing only the scheme and path leaves user@ in the signing host. makeEndpoint accepts that value, region detection still succeeds, and TablePro generates a token signed for user@mydb..., which RDS rejects. Since this code and its new test explicitly support pasted URLs, extract the URL authority/host and port with URLComponents (or reject URLs containing userinfo) rather than slicing the string.
Useful? React with 👍 / 👎.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Follow-up to #1432, from @imdkbj's report that IAM auth still fails while a hand-generated token works:
Root cause
An RDS IAM token is a SigV4 presigned URL whose signature covers
Host: <host>:<port>, and RDS validates it against its own endpoint. The address the client dials does not have to match; the address the token was signed for does. TablePro signed the token with the connection handed to the driver, which is the endpoint it dials, not the one it talks to.That is the wrong endpoint in two cases:
tunneledConnectionrewrites host and port to127.0.0.1:<local port>for all four tunnel kinds, and preserved the original only for pgpass. So RDS IAM over SSH, Cloudflare, Cloud SQL Auth Proxy, or SOCKS signed a token for loopback and was rejected every time. Region detection failed the same way, which is why the docs told tunnel users to fill in the region by hand: that never could have worked either.127.0.0.1:54321is outside TablePro's tunnel port range, so the reporter runs their own forward. TablePro had no way to know the real endpoint and signed a doomed token in silence.Only MySQL, MariaDB, and PostgreSQL are affected. ElastiCache signs a replication group ID and Keyspaces signs a region, neither of which carries a host.
Changes
tunneledConnectionrecords it for every tunnel kind instead of the pgpass-onlypgpassOriginalHostcarve-out, and both pgpass and IAM readpreTunnelHost/preTunnelPort. It travels inadditionalFields, so it survives the health-monitor reconnect and the metadata connection pool, which both rebuild drivers from the stored effective connection.RDSSigningEndpointResolver, pure and no I/O: endpoint override, then the pre-tunnel endpoint, then the configured endpoint. The region derives from the signing host, so a tunneled RDS connection no longer needs the region typed in.RDS Endpointfield inhost[:port]form, for a forward TablePro did not open or a CNAME. The port falls back to the engine default. DBeaver added the same field for the same report (dbeaver#15141), as did DataGrip's AWS toolkit.PAM authentication failed.AWSAuthFields.standard(); they now call it. That also fixes drift the copies had already picked up: they were missing.withDynamicOptions(.awsProfiles), so MySQL and PostgreSQL showed a plain Profile Name text field while MariaDB showed the list of profiles on disk.PluginKit ABI
Two cases on the non-
@frozenAWSAuthErrorand one new static func onAWSAuthFields.scripts/check-pluginkit-abi.shagainstorigin/mainreports those three lines added and nothing removed, renamed, or resignatured, so this is additive: nocurrentPluginKitVersionbump and no plugin re-release. Labelledabi-additive.Tests
RDSSigningEndpointResolverTestscovers the precedence chain, an override with and without a port, a pasted URL, malformed input, and loopback rejection for both the configured and the pre-tunnel host.DatabaseManagerTunnelTestsasserts the pre-tunnel endpoint is recorded for a tunneled connection and absent for a direct one.RegistryAWSIAMFieldsTestschecks the new field reaches MySQL, MariaDB, and PostgreSQL, that the shared AWS field set does not carry it (so ElastiCache and Keyspaces never show it), and that the profile field lists profiles on all three.Docs:
docs/databases/aws-iam.mdxgains a tunnels and port forwards section, corrected region guidance, and troubleshooting for both the new error and the PAM failure.