summaryrefslogtreecommitdiff
path: root/src/common
AgeCommit message (Collapse)Author
2016-11-03Work around a behavior change in openssl's BUF_MEM codeNick Mathewson
In our code to write public keys to a string, for some unfathomable reason since 253f0f160e1185c, we would allocate a memory BIO, then set the NOCLOSE flag on it, extract its memory buffer, and free it. Then a little while later we'd free the memory buffer with BUF_MEM_free(). As of openssl 1.1 this doesn't work any more, since there is now a BIO_BUF_MEM structure that wraps the BUF_MEM structure. This BIO_BUF_MEM doesn't get freed in our code. So, we had a memory leak! Is this an openssl bug? Maybe. But our code was already pretty silly. Why mess around with the NOCLOSE flag here when we can just keep the BIO object around until we don't need the buffer any more? Fixes bug 20553; bugfix on 0.0.2pre8
2016-08-19Avoid confusing GCC 4.2.1 by saying "int foo()... inline int foo() {...}"Nick Mathewson
Fixes bug 19903; bugfix on 0.2.8.1-alpha.
2016-07-21Coverity hates it when we do "E1 ? E2 : E2".Nick Mathewson
It says, 'Incorrect expression (IDENTICAL_BRANCHES)' Fix for CID 1364127. Not in any released Tor.
2016-07-17Merge remote-tracking branch 'weasel/bug19660' into maint-0.2.8Nick Mathewson
2016-07-13Merge remote-tracking branch 'Jigsaw52/seccomp-fix-18397' into maint-0.2.8Nick Mathewson
2016-07-11Add (SOCK_DGRAM, IPPROTO_UDP) sockets to the sandboxing whitelistPeter Palfrader
If we did not find a non-private IPaddress by iterating over interfaces, we would try to get one via get_interface_address6_via_udp_socket_hack(). This opens a datagram socket with IPPROTO_UDP. Previously all our datagram sockets (via libevent) used IPPROTO_IP, so we did not have that in the sandboxing whitelist. Add (SOCK_DGRAM, IPPROTO_UDP) sockets to the sandboxing whitelist. Fixes bug 19660.
2016-07-09Adds missing syscalls to seccomp filter.Daniel Pinto
Fixes #18397 which prevented tor starting with Sandbox 1.
2016-06-24Bug19499: Fix GCC warnings when building against bleeding edge OpenSSL.Yawning Angel
The previous version of the new accessors didn't specify const but it was changed in master.
2016-06-14Resolve the remaining openssl "-Wredundant-decls" warnings.Nick Mathewson
Another part of 19406
2016-06-14Bug 19406: OpenSSL removed SSL_R_RECORD_TOO_LARGE in 1.1.0.Yawning Angel
This is a logging onlu change, we were suppressing the severity down to INFO when it occured (treating it as "Mostly harmless"). Now it is no more.
2016-06-14Bug 19406: OpenSSL made RSA and DH opaque in 1.1.0.Yawning Angel
There's accessors to get at things, but it ends up being rather cumbersome. The only place where behavior should change is that the code will fail instead of attempting to generate a new DH key if our internal sanity check fails. Like the previous commit, this probably breaks snapshots prior to pre5.
2016-06-14Bug 19406: OpenSSL changed the Thread API in 1.1.0 again.Yawning Angel
Instead of `ERR_remove_thread_state()` having a modified prototype, it now has the old prototype and a deprecation annotation. Since it's pointless to add extra complexity just to remain compatible with an old OpenSSL development snapshot, update the code to work with 1.1.0pre5 and later.
2016-05-25Merge branch 'bug19161_028_v2' into maint-0.2.8Nick Mathewson
2016-05-25Merge branch 'bug19152_024_v2' into maint-0.2.8Nick Mathewson
2016-05-25Fix a dangling pointer issue in our RSA keygen codeNick Mathewson
If OpenSSL fails to generate an RSA key, do not retain a dangling pointer to the previous (uninitialized) key value. The impact here should be limited to a difficult-to-trigger crash, if OpenSSL is running an engine that makes key generation failures possible, or if OpenSSL runs out of memory. Fixes bug 19152; bugfix on 0.2.1.10-alpha. Found by Yuan Jochen Kang, Suman Jana, and Baishakhi Ray. This is potentially scary stuff, so let me walk through my analysis. I think this is a bug, and a backport candidate, but not remotely triggerable in any useful way. Observation 1a: Looking over the OpenSSL code here, the only way we can really fail in the non-engine case is if malloc() fails. But if malloc() is failing, then tor_malloc() calls should be tor_asserting -- the only way that an attacker could do an exploit here would be to figure out some way to make malloc() fail when openssl does it, but work whenever Tor does it. (Also ordinary malloc() doesn't fail on platforms like Linux that overcommit.) Observation 1b: Although engines are _allowed_ to fail in extra ways, I can't find much evidence online that they actually _do_ fail in practice. More evidence would be nice, though. Observation 2: We don't call crypto_pk_generate*() all that often, and we don't do it in response to external inputs. The only way to get it to happen remotely would be by causing a hidden service to build new introduction points. Observation 3a: So, let's assume that both of the above observations are wrong, and the attacker can make us generate a crypto_pk_env_t with a dangling pointer in its 'key' field, and not immediately crash. This dangling pointer will point to what used to be an RSA structure, with the fields all set to NULL. Actually using this RSA structure, before the memory is reused for anything else, will cause a crash. In nearly every function where we call crypto_pk_generate*(), we quickly use the RSA key pointer -- either to sign something, or to encode the key, or to free the key. The only exception is when we generate an intro key in rend_consider_services_intro_points(). In that case, we don't actually use the key until the intro circuit is opened -- at which point we encode it, and use it to sign an introduction request. So in order to exploit this bug to do anything besides crash Tor, the attacker needs to make sure that by the time the introduction circuit completes, either: * the e, d, and n BNs look valid, and at least one of the other BNs is still NULL. OR * all 8 of the BNs must look valid. To look like a valid BN, *they* all need to have their 'top' index plus their 'd' pointer indicate an addressable region in memory. So actually getting useful data of of this, rather than a crash, is going to be pretty damn hard. You'd have to force an introduction point to be created (or wait for one to be created), and force that particular crypto_pk_generate*() to fail, and then arrange for the memory that the RSA points to to in turn point to 3...8 valid BNs, all by the time the introduction circuit completes. Naturally, the signature won't check as valid [*], so the intro point will reject the ESTABLISH_INTRO cell. So you need to _be_ the introduction point, or you don't actually see this information. [*] Okay, so if you could somehow make the 'rsa' pointer point to a different valid RSA key, then you'd get a valid signature of an ESTABLISH_INTRO cell using a key that was supposed to be used for something else ... but nothing else looks like that, so you can't use that signature elsewhere. Observation 3b: Your best bet as an attacker would be to make the dangling RSA pointer actually contain a fake method, with a fake RSA_private_encrypt function that actually pointed to code you wanted to execute. You'd still need to transit 3 or 4 pointers deep though in order to make that work. Conclusion: By 1, you probably can't trigger this without Tor crashing from OOM. By 2, you probably can't trigger this reliably. By 3, even if I'm wrong about 1 and 2, you have to jump through a pretty big array of hoops in order to get any kind of data leak or code execution. So I'm calling it a bug, but not a security hole. Still worth patching.
2016-05-25Merge branch 'memarea_overflow_027_squashed' into maint-0.2.8Nick Mathewson
2016-05-25Fix a pointer arithmetic bug in memarea_alloc()Nick Mathewson
Fortunately, the arithmetic cannot actually overflow, so long as we *always* check for the size of potentially hostile input before copying it. I think we do, though. We do check each line against MAX_LINE_LENGTH, and each object name or object against MAX_UNPARSED_OBJECT_SIZE, both of which are 128k. So to get this overflow, we need to have our memarea allocated way way too high up in RAM, which most allocators won't actually do. Bugfix on 0.2.1.1-alpha, where memarea was introduced. Found by Guido Vranken.
2016-05-24Make sure that libscrypt_scrypt actually exists before using it.Nick Mathewson
Previously, if the header was present, we'd proceed even if the function wasn't there. Easy fix for bug 19161. A better fix would involve trying harder to find libscrypt_scrypt.
2016-05-12Merge branch 'maint-0.2.7' into maint-0.2.8Nick Mathewson
2016-05-12Merge branch 'bug18977_026_v2' into maint-0.2.7Nick Mathewson
2016-05-12Merge branch 'bug18977_024_v2' into bug18977_026_v2Nick Mathewson
Had conflicts related to other correct_tm bugs in 0.2.6. Added wday for another case.
2016-05-12Have correct_tm set tm_wday as well.Nick Mathewson
The tm_wday field had been left uninitialized, which was causing some assertions to fail on Windows unit tests. Fixes bug 18977.
2016-05-04Merge branch 'bug18686_025' into maint-0.2.8Nick Mathewson
2016-05-04Report success when not terminating an already terminated process.Nick Mathewson
Also, document the actual behavior and return values of tor_terminate_process. Fixes bug18686; bugfix on 0.2.3.9-alpha.
2016-04-12Merge remote-tracking branch 'public/bug18716_027' into maint-0.2.8Nick Mathewson
2016-04-07memarea: Don't assume that sizeof(ulong) >= sizeof(void*).Nick Mathewson
Fixes bug 18716; bugfix on 0.2.1.1-alpha where memarea.c was introduced. Found by wbenny.
2016-04-05Only define NEW_THREAD_API when not building with LibreSSL.Nick Mathewson
2016-04-05OpenSSL 1.1.0-pre5-dev and later made BIO opaque.Yawning Angel
Detect newer versions and fix our TLS code to use the new API.
2016-04-05OpenSSL 1.1.0-pre4 and later(?) have a new "thread API".Yawning Angel
It appears that setting the various callbacks is no longer required, so don't.
2016-03-26Do not treat "DOCDOC" as doxygen.Nick Mathewson
2016-03-26add a little documentation to memarea. (I have been testing a tool.)Nick Mathewson
2016-03-26Whitespace fixesNick Mathewson
2016-03-26Fix all doxygen warnings (other than missing docs)Nick Mathewson
2016-03-25Only check in-boundsness of seconds when time_t is smaller than i64Nick Mathewson
Otherwise coverity complains that we're checking an whether an int64 is less than INT64_MIN, which of course it isn't. Fixes CID 1357176. Not in any released Tor.
2016-03-24Merge branch 'timegm_overflow_squashed'Nick Mathewson
2016-03-24Avoid overflow in tor_timegm on 32 bit platforms due to year 2038teor (Tim Wilson-Brown)
2016-03-22Repair build when no sandbox support is enabled.Nick Mathewson
2016-03-22Merge remote-tracking branch 'public/bug18253'Nick Mathewson
2016-03-22Fix an fd leak in check_private_dir().Nick Mathewson
The fd would leak when the User wasn't recogniezed by getpwnam(). Since we'd then go on to exit, this wasn't a terribad leak, but it's still not as nice as no leak at all. CID 1355640; bugfix on no released Tor.
2016-03-15Fix whitespace.Nick Mathewson
2016-03-15Merge remote-tracking branch 'weasel/bug18458'Nick Mathewson
2016-03-14Merge branch 'bug15221_027'Nick Mathewson
2016-03-14Make unix sockets work with the linux seccomp2 sandbox againNick Mathewson
I didn't want to grant blanket permissions for chmod() and chown(), so here's what I had to do: * Grant open() on all parent directories of a unix socket * Write code to allow chmod() and chown() on a given file only. * Grant chmod() and chown() on the unix socket.
2016-03-14Permit setrlimit, prlimit, prlimit64 calls.Nick Mathewson
We call setrlimit under some circumstances, and it can call prlimit and prlimit64 under the hood. Fixes bug 15221.
2016-03-14When using open() to make sure we created a dir, close the fd afterwardsNick Mathewson
Found by coverity. Not in any released Tor. Fixes CID 1355640. Also, don't check for fd correctness with assert(fd). You need to assert (fd >= 0).
2016-03-04Correctly duplicate addresses in get_interface_address6_listteor (Tim Wilson-Brown)
2016-03-04Avoid freeing an uninitialised pointer in get_interface_addresses_ioctlteor (Tim Wilson-Brown)
2016-03-01First RelaxDirModeCheck implementationPeter Palfrader
2016-02-28clean/extend some module docs, including fix from #18403Nick Mathewson
2016-02-27Update the copyright year.Nick Mathewson