Repository navigation
0.3.1
Security
nimgrpc/health: a request (or, for the client, a response) with a protobuf wire type that does not exist (6 or 7) ended the program with a RangeDefect: the 7-byte body00 00 00 00 02 0e 00sent to/grpc.health.v1.Health/Checkstopped any server that registered the health service, with no authentication. In 0.3.0 only (the service is new there). The decoders now raiseProtobufError, which the server answers with INVALID_ARGUMENT.- A small request could crash a server, or a client reading a reply: the Protobuf decoder had no limit on how deep messages nest.
skipFieldskipped a group (an unknown proto2 start-group, two bytes0xC3 0x3Efor field 1000) by recursing, so a body of such pairs made it recurse once per pair; 200 KB overflowed the stack of a blocking-server worker thread, anddecodeHealthRequeston 600 KB overflowed the 8 MB main stack, which is where the chronos server runs handlers. Messages nested inside messages (a recursive type such asmessage Node { Node child = 2; }) recursed the same way:Node.decodeof a 700 000-level chain of 3.5 MB crashed with a segmentation fault (run on the code of 0.3.0, a release build). Every program that decodes Protobuf it did not write is affected, all versions up to 0.3.0: the generateddecode, the health service, reflection and the well-known types. The message limit (4 MiB by default) did not help, as 2 000 000 groups fit in it. Fixed: decoding stops withProtobufError("message nested too deeply") pastmaxNestingDepth(100, the limit of protobuf-go and C++ protobuf); a server answers INTERNAL, as for any message it cannot decode. Groups are now skipped without recursion. Generated code needs no regeneration: it reads a nested message throughsubReader, which now carries and checks the depth. Tests:tests/tcodec.nim(suite "nesting limit"),tests/tgrpc.nimandtests/tasyncgrpc.nim(a 200 KB group bomb to a server, then a normal call), and a seed intools/fuzz.nim.
Added
- TLS: a server dialled by an IP address ("10.0.0.5", "::1", "[::1]"), or with
serverNamean IP address, is checked against the iPAddress entries of its certificate (subjectAltName), as RFC 6125 says; before, only DNS names could be verified, so a service on an address without a name could not use TLS with verification. No SNI is sent for an IP address (RFC 6066). Tests:tests/ttls.nim.
Fixed
TlsConfigshared by several threads: a configuration handed to more than one thread was a Nimrefcopied between them, and ORC counts references without atomics, so it could be freed while a handshake still read its trust anchors (SIGSEGV in a program that connects afresh from several threads; found by a soak run). The configuration now has an atomic count of owners and each connection holds one.share(c)gives a thread or a connection its own object over the same configuration and the same resumable sessions; use it when aTlsConfigcrosses threads.
Upgrade notes: docs/upgrading.md (section 0.3.1).