WireGuard Archive on lore.kernel.org
 help / color / Atom feed
* Re: Let's talk about obfuscation again
       [not found] <mailman.1542.1536245115.2201.wireguard@lists.zx2c4.com>
@ 2018-09-06 15:24 ` Brian Candler
  2018-09-06 21:16   ` James Cloos
  0 siblings, 1 reply; 9+ messages in thread
From: Brian Candler @ 2018-09-06 15:24 UTC (permalink / raw)
  To: wireguard

> Domain fronting seems like the stealthiest option to me (and if anyone has a reliable way to
> detect domain fronting, I would love to hear about it!). But that doesn?t get you UDP (and NAT
> traversal); perhaps VOIP/WebRTC mimicry could work?

I think this is a game you can't win against a suitably motivated adversary.  Such an adversary can and will decode the payload to see if it makes sense.

For example: an apparently unencrypted VOIP/WebRTC stream, but one which contains "random" payload (i.e. which doesn't decode properly through the declared codec, or decodes to noise) may be interpreted as an encrypted phone call, and blocked on that basis alone, even if it's not obvious it contains data.

It would also be massively inefficient.  On the one hand, you'd have to send a stream of padding packets when there is no data to send, to look like an idle phone/video call.  On the other hand, when you *do* have data to send, you would have to constrain your bandwidth so you don't burst above a level of traffic which such a call would normally generate.

OK, so what about changing wireguard to use TCP and TLS on port 443? It's still going to look very anomolous compared to a "normal" web exchange.  Conceivably it might be mistaken for a websockets-based chat application or XMPP; but any adversary who wants to block wireguard is presumably going to want to block encrypted chat too.

In summary: I think wireguard is a tool for connecting together island networks, over an untrusted but cooperative intermediate network.  I don't think it should turn into a tool for steganography or policy busting.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Let's talk about obfuscation again
  2018-09-06 15:24 ` Let's talk about obfuscation again Brian Candler
@ 2018-09-06 21:16   ` James Cloos
  0 siblings, 0 replies; 9+ messages in thread
From: James Cloos @ 2018-09-06 21:16 UTC (permalink / raw)
  To: wireguard; +Cc: Brian Candler

>>>>> "BC" == Brian Candler <b.candler@pobox.com> writes:

BC> OK, so what about changing wireguard to use TCP and TLS on port 443?

Using udp/443 for one end could allow making it look like quic.

You'd need non-wg traffic on the port to reply like a quic server would.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Let's talk about obfuscation again
  2018-09-06 15:19     ` Fredrik Strömberg
@ 2018-09-07  8:49       ` StarBrilliant
  0 siblings, 0 replies; 9+ messages in thread
From: StarBrilliant @ 2018-09-07  8:49 UTC (permalink / raw)
  To: Fredrik Strömberg, Jason A. Donenfeld; +Cc: wireguard

On Fri, Sep 7, 2018 at 1:20 AM Fredrik Str=C3=B6mberg <stromberg@mullvad.ne=
t> wrote:
> Using Pluggable Transports seem like a good solution. Simply divert
> WireGuard traffic to a local UDP port, which then sends it using a
> Pluggable Transport over the Internet to the other WireGuard peer.
>
> StarBrilliant: You indicated that some aspect of WireGuard ("solve the
> padding and timing problem so PT plugins can run on top of it")
> prevents Pluggable Transports from working. Please elaborate.


On Fri, Sep 7, 2018 at 2:11 AM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> This is generally what I'd recommend too, but I'm not sure I follow
> the logic of the padding and timing. Should not a proper pluggable
> transport be doing this on its own already? Adding random padding to
> all packets, and delaying statistically similar ones randomly as well?
> Especially for the padding aspect, there's little reason why a
> pluggable transport should not already be doing this.


Hello everyone,

Thank you for your attention. I will address the two questions above togeth=
er.

We assume Pluggable Transport to be a universal plug-in. (I don't talk
of *a specific* Pluggable Transport program here, because as I already
knew, there aren't any PT that supports UDP yet. We will still need to
build a UDP-supported PT in the future.)

A Pluggable Transport can and should:
- Scramble the data so it looks like another protocol or random noise.
- Combine and split packets so 1 packet can be 2, 2 can be 1.
- Pad the data so the packet length is not identical to the original.
- Apply delay & jitter so packets does not follow a uniform temporal
pattern. (Sadly, experiments show reordering would terribly affect the
TCP performance in a VPN so we would not turn delay & jitter on by
default)

But a Pluggable Transport CAN NOT:
- Identify whether the inner protocol is Wireguard or SSH or Tor.
- Have knowledge that the "Client Handshake" length=3D148, the "Server
Handshake" length=3D92, the "Keep Alive" length=3D32.
- Swallow any of the packet based on the inside of the packet, except
for traffic shaping & rate limiting.
- Pad the packet too long. (e.g. don't expect 32 -> 1472)
- Delay a packets for minutes long, it can only operate on milliseconds lev=
el.

We know even on an idle connection, the "Client Handshake" is sent
every X minutes, immediately followed by a "Server Handshake". And
"Keep Alive" is sent every Y minutes (configurable by the user, used
for NAT scenarios).

I hope three changes applied to Wireguard:
- For "Client Handshake", "Server Handshake" and "Keep Alive", since
they can be pad to any length without affecting compatibility, why not
pad them to any length below 1472?
- For data packets, leave them as is and let PT do the padding.
- The rekey and keep-alive are sent in random(X-D, X) time, and the
server expect a rekey in a window of range(0, X). D can be as long as
minutes or as long as 50% of X.
- Allow Wireguard to bind to only one or more specific local addresses
(e.g. only ::1). Therefore we do not need to use complicated firewall
setup to prevent WG from directly expose to the Internet.


Best regards.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Let's talk about obfuscation again
  2018-09-06  0:06 StarBrilliant
  2018-09-06  8:43 ` Dennis Jackson
@ 2018-09-06 16:10 ` Jason A. Donenfeld
  1 sibling, 0 replies; 9+ messages in thread
From: Jason A. Donenfeld @ 2018-09-06 16:10 UTC (permalink / raw)
  To: coder; +Cc: WireGuard mailing list

Hey SB,

Thanks for the detailed post and insights.

Indeed obfuscation is an extremely useful tool. WireGuard itself is
derived from an exfiltration mechanism of mine, and so I've written
quite a few different obfuscation modules for that. When the core
WireGuard engineering becomes a bit more relaxed (right now it's
pretty intense), I may devote some effort into cleaning these up and
making them available as generic methods for whatever packet flow.

One thing to consider with obfuscation is: what type do you need and
for what purpose? What is your adversary like, and what policies are
they trying to enforce? For example, any one of these methods are
useful in a particular circumstance:

- Turn the entire stream into noise with something like xchacha or aes-pmac-siv.
- Turn the stream into noise and then walk a markov chain to generate
something that looks like HTML.
- Turn the stream into noise and then walk a markov chain to generate
something that looks like h264.
- Turn the stream into noise and then walk a markov chain to generate
something that looks like TLS 1.0.
- Turn the stream into noise and then encode the traffic as DNS requests.
- Turn the stream into noise and then walk a markov chain to generate
something that looks like DNS.
- Generate a training set using traffic gathered from eth0, turn the
stream into noise, and then use the training set to generate traffic
that looks like normal traffic.
- Generate a training set using traffic gathered from an implant on
another box, turn the stream into noise, and then use the training set
to generate traffic that looks like normal traffic.
- Manually provide a hand crafted training set, turn the stream into
noise, and then use the training set to generate traffic that looks
like normal traffic.
- Turn the stream into noise, and manually encode that into some given format.
- Turn the stream into noise, and then inject as corrupt ethernet frames.
- Turn the stream into noise, and then delay existing packets with a
modulated encoding to create a side channel.

The list goes on. These have all been useful in different
circumstances, and there are many more like them. I'm not too familiar
with the pluggable transports project, but my understanding is that it
is motivated by precisely this insight: there are many valid and
useful means of obfuscation, each of which is useful and has different
trade-offs. So why not make it pluggable? I generally don't like
mega-abstracted and pluggable big complicated things, as a general
taste, but here I think one has a decent argument as to why this might
make sense.

So of your suggestions, the most compelling one is:

> - Remain plaintext, but fix padding and timing problem,
>  relying Pluggable Transport [4] plugins to do the remaining work.
>  (I really recommend this solution.)

This is generally what I'd recommend too, but I'm not sure I follow
the logic of the padding and timing. Should not a proper pluggable
transport be doing this on its own already? Adding random padding to
all packets, and delaying statistically similar ones randomly as well?
Especially for the padding aspect, there's little reason why a
pluggable transport should not already be doing this.

Jason

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Let's talk about obfuscation again
  2018-09-06 14:45   ` George Walker
  2018-09-06 15:19     ` Fredrik Strömberg
@ 2018-09-06 15:34     ` Dennis Jackson
  1 sibling, 0 replies; 9+ messages in thread
From: Dennis Jackson @ 2018-09-06 15:34 UTC (permalink / raw)
  To: George Walker; +Cc: wireguard

[-- Attachment #1: Type: text/plain, Size: 2182 bytes --]

On Thu, 6 Sep 2018 17:19:57 +0200
Fredrik Strömberg <stromberg@mullvad.net> wrote:

>> First of all, censorship circumvention is an important societal
>> problem to solve. It is also clearly outside of the scope of
>> WireGuard. Any suggested protocol change with that motive will
>> increase the complexity of the code base, which increases the risk
>> of vulnerabilities. This would hurt all WireGuard users.

Amen! 

On Thu, 6 Sep 2018 10:45:24 -0400
George Walker <georgewalkeriv@gmail.com> wrote:

> The objective of cleaning as described seems to be to make the
> protocol indistinguishable from exchanging random payloads. But are
> there any common protocols of commercial importance that are so
> inscrutable? If I saw such random-looking UDP payloads on the wire I
> would suspect malware c&c, file sharing (who remembers FreeNet?), or
> a tunnel, depending on data volume and direction —nothing I would
> hesitate to block (or flag as suspicious) if I were running a big
> traffic classifier.

There is a few different purposes served by this transform: 

a) By having a uniformly random stream, its much easier to plug in to
various mimicry tools (as you suggest) since you know the input data
doesn't contain any meaning. There's some good work from the Tor people
on this kind of thing. For example, 'cleaned' traffic could be made to
look like TLS, without doubly encrypting every packet with the TLS key,
instead the UDP data can be passed through directly. 

b) From a surveillance perspective, it becomes harder to identify and
record traffic. The classification goes from being "WG-VPN" to "???".
This makes the analysts job a bit harder. Increasing labour costs is
probably more painful for such entities than anything else. 

c) It forces a censor to move from a blacklisting approach  to a
whitelisting approach. As you say, this won't stymie the great firewall
of China but developing a rule to block traffic which looks "too
random" without too many false positives requires a lot of resources
and we can exploit this. 

Best,
Dennis 

-- 
PGP Fingerprint: 5B93 F0B9 D6A8 9BC1 546B C98C 6105 A775 8CD2 46AC

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Let's talk about obfuscation again
  2018-09-06 14:45   ` George Walker
@ 2018-09-06 15:19     ` Fredrik Strömberg
  2018-09-07  8:49       ` StarBrilliant
  2018-09-06 15:34     ` Dennis Jackson
  1 sibling, 1 reply; 9+ messages in thread
From: Fredrik Strömberg @ 2018-09-06 15:19 UTC (permalink / raw)
  To: WireGuard mailing list

Hi everyone,

First of all, censorship circumvention is an important societal
problem to solve. It is also clearly outside of the scope of
WireGuard. Any suggested protocol change with that motive will
increase the complexity of the code base, which increases the risk of
vulnerabilities. This would hurt all WireGuard users.

Secondly, the experience from Tor's Pluggable Transports, Psiphon,
Lantern, and various VPN services, clearly shows that DPI
circumvention methods need to be updated regularly. Whatever ideas you
have will be fingerprinted and blocked eventually.

Using Pluggable Transports seem like a good solution. Simply divert
WireGuard traffic to a local UDP port, which then sends it using a
Pluggable Transport over the Internet to the other WireGuard peer.

StarBrilliant: You indicated that some aspect of WireGuard ("solve the
padding and timing problem so PT plugins can run on top of it")
prevents Pluggable Transports from working. Please elaborate.

Cheers,
Fredrik Stromberg

On Thu, Sep 6, 2018 at 4:45 PM, George Walker <georgewalkeriv@gmail.com> wr=
ote:
> The userspace daemon would:
>    - 'Clean' Wireguard [handshake/data] packets
>
>
> The objective of cleaning as described seems to be to make the protocol
> indistinguishable from exchanging random payloads. But are there any comm=
on
> protocols of commercial importance that are so inscrutable? If I saw such
> random-looking UDP payloads on the wire I would suspect malware c&c, file
> sharing (who remembers FreeNet?), or a tunnel, depending on data volume a=
nd
> direction =E2=80=94nothing I would hesitate to block (or flag as suspicio=
us) if I
> were running a big traffic classifier.
>
> Domain fronting seems like the stealthiest option to me (and if anyone ha=
s a
> reliable way to detect domain fronting, I would love to hear about it!). =
But
> that doesn=E2=80=99t get you UDP (and NAT traversal); perhaps VOIP/WebRTC=
 mimicry
> could work?
>
>
> Best,
> George
>
>
> Sent from my iPhone
>
> On Sep 6, 2018, at 4:43 AM, Dennis Jackson <dennis.jackson@cs.ox.ac.uk>
> wrote:
>
> Hi,
>
> I've been thinking about this issue as well and I agree it's an
> important one to solve. However, Wireguard's key selling points are its
> performance, simple configuration and minimal code size and I don't
> think we can compromise this. So I was wondering if a userspace program
> which obfuscates outgoing Wireguard packets and de-obfuscates incoming
> packets might solve the problem, without impacting Wireguard's key
> features.
>
> The userspace daemon would:
>    - 'Clean' Wireguard handshake packets,
>        * Randomise the packet type field
>        * Convert the ephemeral key to Elligator encoding
>        * Randomise the mac field if unused
>        * Random padding to alter packet lengths
>    - 'Clean' Data packets
>        * The header is exactly 16 bytes and non-repeating so
>          transform with AES-ECB
>        * The key could be derived from a PSK and the public
>          keys used in the handshake (ensuring keys don't
>          repeat)
>        * Or Wireguard could provide a hook for a "post-master
>          secret" which might be useful for many extensions
>    - The resulting stream would (hopefully) be uniformly
>      distributed which can either be transmitted directly or
>      passed to a pluggable transport.
>    - On the receiving end the daemon reverses the transformation
>      and delivers the packets to Wireguard.
>
> Outcome:
>    + Clear separation between codebases
>    + No matter how badly implemented, the userspace daemon can't
>      compromise authenticity or confidentiality.
>    + Easily extensible
>    + Wireguard doesn't need to know about the transformation, it
>      just sends its packets to a listener on the loopback
>      interface.
>    - Performance hit from the packet indirection, ECB encryption
>      etc
>    - Still needs Wireguard to disable cookies, add timing jitter
>      on handshake / keep-alive packets.
>
> I'm sure there are alternatives/better solutions. This is just a
> sketch to show it is possible without altering Wireguard's codebase or
> functionality. If you have any comments or criticism, I'd be interested
> in refining the idea further.
>
> Kind regards,
> Dennis
>
> On Thu, 6 Sep 2018 10:06:07 +1000
> StarBrilliant <coder@poorlab.com> wrote:
>
> Hi,
>
>
> (TL;DR: Please seriously consider preventing WG from being blocked,
>
> for 2/3 of the world's Internet users. No need to break compatibility,
>
> be friendly to PT plugins is a possible solution.)
>
>
> I have been using WG for months. I understand the fact that Wireguard
>
> wants to keep its protocol simple and easy to audit. I also understand
>
> that we have talked about this topic back in 2016. [1]
>
>
>
> ## The problem: way too easy to block
>
>
> I propose this issue again, because Wireguard has recently become a
>
> hot topic in Chinese community with the most strict
>
> <del>Internet</del> Intranet censorship in the world. Chinese
>
> Wireguard users succeeded in access the Internet temporarily, but we
>
> know Wireguard never tries to prevent itself from being blocked.
>
>
> It is indeed very easy to completely block Wireguard protocol with
>
> iptables:
>
> iptables -A FORWARD -p udp -m length --length 120 -m u32 --u32 "0
>
> 22 & 0x3c @ 8 =3D 0x2000000" -j DROP
>
> (Yes, from prior experience of blocking TLS and OpenVPN, usually
>
> Message ID 2 is blocked instead of Message ID 1, probably for the
>
> intention to consume server resources.)
>
>
> It is also possible to interfere with the keep-alive packet, since it
>
> is "always on time like a bus" and exactly 32 bytes:
>
> iptables -A FORWARD -p udp -m length --length 60 -m u32 --u32 "0 >>
>
> 22 & 0x3c @ 8 =3D 0x4000000" -m statistic --mode random --probability
>
> 0.4 -j DROP
>
>
>
> ## But it's unrelated to WG's security model!
>
>
> I heard someone saying something like below:
>
>
> On Sat Jul 9 17:49:47 CEST 2016, Bruno Wolff III <bruno@wolff.to>
>
> wrote:
>
> Given the design goals of wireguard, I don't think it is something
>
> that would be particularly good to combine with steganography. We
>
> need real net neutrality, with ISPs not allowed to block traffic
>
> based on content. We need governments not passing laws to make
>
> people compromise their own security. Using strong unbreakable
>
> encryption when communicating, should be the norm, not something
>
> you need to hide.
>
>
> I interpret those sentences as identical to "Do not use Wireguard if
>
> you live in a country where unlicensed VPN is illegal. Go and ask for
>
> net neutrality instead." But the fact is that 2/3 of the world's
>
> Internet users [2] live in censorship. For most of them, unlicensed
>
> VPN is their only weapon to fight for net neutrality.
>
>
> The undoubted top-1 encrypted proxy software [3] in China was not
>
> written by a crypto professional and even started with RC4-MD5, not
>
> until 5 years later (2017) did it have AEAD cipher.
>
>
> People love Wireguard because of its security, flexibility and
>
> efficiency, but only when it can work. It is useless to talk about
>
> security if it does not work.
>
>
>
> ## Can we solve the problem easily?
>
>
> What makes Wireguard easy to detect?
>
> - Fixed first 4 bytes
>
>  (0x01000000 through 0x04000000)
>
> - Plaintext nounce counter
>
>  (Could XChaCha20 solve the problem?)
>
> - Fixed sender & receiver ID
>
>  (Two-pass encrypt might work, see below)
>
> - Fixed length handshake & keep-alive
>
>  (148, 92, 32. can we pad them longer?)
>
> - Punctual rekey & keep-alive
>
>  (Can we delay them randomly as IPsec do?)
>
>
> How can we solve the problem?
>
> - Embed steganography inside Wireguard?
>
>  (Not realistic. Big codebase, potential bugs.)
>
> - Two-pass encrypt so no more plaintext handshake?
>
>  The outer layer could be PSK and does not need to be PFS.
>
>  (Possible but slow. PSK can be shared among sessions, like
>
> L2TP/IPsec do.)
>
> - Remain plaintext, but fix padding and timing problem,
>
>  relying Pluggable Transport [4] plugins to do the remaining work.
>
>  (I really recommend this solution.)
>
>
> I read the tech whitepaper multiple times. I think it is possible
>
> solve the problem in Method 3 without breaking any compatibility. For
>
> Message ID =3D 1, 2, 3, we can add random data at the end of the packet.
>
> For Message ID =3D 4 and Length =3D 0 (keep-alive packet), we can add mor=
e
>
> zeros in the encapsulated packet. For the timing problem, we can give
>
> rekey and keep-alive a little bit randomness.
>
>
> In conclusion, I think we do not need to break the compatibility or
>
> bloat the code base to make Wireguard immune to being detected. We
>
> could either two-pass encrypt the packet, or solve the padding and
>
> timing problem so PT plugins can run on top of it. I hope to see
>
> Wireguard run anywhere without worries, not only on devices owned by
>
> 1/3 of the Internet's population.
>
>
>
> ## Notes
>
>
> [1] https://lists.zx2c4.com/pipermail/wireguard/2016-July/000184.html
>
> [2] https://www.theverge.com/2016/11/14/13596974/
>
> [3] https://github.com/shadowsocks/shadowsocks (Please switch git
>
> branch to see the actual code)
>
> [4]
>
> https://www.torproject.org/docs/pluggable-transports.html.en#list-of-pts
>
>
>
> Best regards.
>
> _______________________________________________
>
> WireGuard mailing list
>
> WireGuard@lists.zx2c4.com
>
> https://lists.zx2c4.com/mailman/listinfo/wireguard
>
>
>
>
> --
> PGP Fingerprint: 5B93 F0B9 D6A8 9BC1 546B C98C 6105 A775 8CD2 46AC
>
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard
>
>
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Let's talk about obfuscation again
  2018-09-06  8:43 ` Dennis Jackson
@ 2018-09-06 14:45   ` George Walker
  2018-09-06 15:19     ` Fredrik Strömberg
  2018-09-06 15:34     ` Dennis Jackson
  0 siblings, 2 replies; 9+ messages in thread
From: George Walker @ 2018-09-06 14:45 UTC (permalink / raw)
  To: Dennis Jackson; +Cc: wireguard

[-- Attachment #1: Type: text/plain, Size: 8770 bytes --]

> The userspace daemon would:
>    - 'Clean' Wireguard [handshake/data] packets

The objective of cleaning as described seems to be to make the protocol indistinguishable from exchanging random payloads. But are there any common protocols of commercial importance that are so inscrutable? If I saw such random-looking UDP payloads on the wire I would suspect malware c&c, file sharing (who remembers FreeNet?), or a tunnel, depending on data volume and direction —nothing I would hesitate to block (or flag as suspicious) if I were running a big traffic classifier.

Domain fronting seems like the stealthiest option to me (and if anyone has a reliable way to detect domain fronting, I would love to hear about it!). But that doesn’t get you UDP (and NAT traversal); perhaps VOIP/WebRTC mimicry could work?


Best,
George


Sent from my iPhone

> On Sep 6, 2018, at 4:43 AM, Dennis Jackson <dennis.jackson@cs.ox.ac.uk> wrote:
> 
> Hi, 
> 
> I've been thinking about this issue as well and I agree it's an
> important one to solve. However, Wireguard's key selling points are its
> performance, simple configuration and minimal code size and I don't
> think we can compromise this. So I was wondering if a userspace program
> which obfuscates outgoing Wireguard packets and de-obfuscates incoming
> packets might solve the problem, without impacting Wireguard's key
> features. 
> 
> The userspace daemon would:
>    - 'Clean' Wireguard handshake packets, 
>        * Randomise the packet type field
>        * Convert the ephemeral key to Elligator encoding
>        * Randomise the mac field if unused
>        * Random padding to alter packet lengths
>    - 'Clean' Data packets
>        * The header is exactly 16 bytes and non-repeating so
>          transform with AES-ECB
>        * The key could be derived from a PSK and the public
>          keys used in the handshake (ensuring keys don't
>          repeat)
>        * Or Wireguard could provide a hook for a "post-master
>          secret" which might be useful for many extensions
>    - The resulting stream would (hopefully) be uniformly
>      distributed which can either be transmitted directly or
>      passed to a pluggable transport. 
>    - On the receiving end the daemon reverses the transformation
>      and delivers the packets to Wireguard.
> 
> Outcome:
>    + Clear separation between codebases
>    + No matter how badly implemented, the userspace daemon can't
>      compromise authenticity or confidentiality. 
>    + Easily extensible
>    + Wireguard doesn't need to know about the transformation, it
>      just sends its packets to a listener on the loopback
>      interface.
>    - Performance hit from the packet indirection, ECB encryption
>      etc
>    - Still needs Wireguard to disable cookies, add timing jitter
>      on handshake / keep-alive packets. 
> 
> I'm sure there are alternatives/better solutions. This is just a
> sketch to show it is possible without altering Wireguard's codebase or
> functionality. If you have any comments or criticism, I'd be interested
> in refining the idea further. 
> 
> Kind regards,
> Dennis
> 
> On Thu, 6 Sep 2018 10:06:07 +1000
> StarBrilliant <coder@poorlab.com> wrote:
> 
>> Hi,
>> 
>> (TL;DR: Please seriously consider preventing WG from being blocked,
>> for 2/3 of the world's Internet users. No need to break compatibility,
>> be friendly to PT plugins is a possible solution.)
>> 
>> I have been using WG for months. I understand the fact that Wireguard
>> wants to keep its protocol simple and easy to audit. I also understand
>> that we have talked about this topic back in 2016. [1]
>> 
>> 
>> ## The problem: way too easy to block
>> 
>> I propose this issue again, because Wireguard has recently become a
>> hot topic in Chinese community with the most strict
>> <del>Internet</del> Intranet censorship in the world. Chinese
>> Wireguard users succeeded in access the Internet temporarily, but we
>> know Wireguard never tries to prevent itself from being blocked.
>> 
>> It is indeed very easy to completely block Wireguard protocol with
>> iptables:
>>> iptables -A FORWARD -p udp -m length --length 120 -m u32 --u32 "0
>>>>> 22 & 0x3c @ 8 = 0x2000000" -j DROP  
>> (Yes, from prior experience of blocking TLS and OpenVPN, usually
>> Message ID 2 is blocked instead of Message ID 1, probably for the
>> intention to consume server resources.)
>> 
>> It is also possible to interfere with the keep-alive packet, since it
>> is "always on time like a bus" and exactly 32 bytes:
>>> iptables -A FORWARD -p udp -m length --length 60 -m u32 --u32 "0 >>
>>> 22 & 0x3c @ 8 = 0x4000000" -m statistic --mode random --probability
>>> 0.4 -j DROP  
>> 
>> 
>> ## But it's unrelated to WG's security model!
>> 
>> I heard someone saying something like below:
>> 
>> On Sat Jul 9 17:49:47 CEST 2016, Bruno Wolff III <bruno@wolff.to>
>> wrote:
>>> Given the design goals of wireguard, I don't think it is something
>>> that would be particularly good to combine with steganography. We
>>> need real net neutrality, with ISPs not allowed to block traffic
>>> based on content. We need governments not passing laws to make
>>> people compromise their own security. Using strong unbreakable
>>> encryption when communicating, should be the norm, not something
>>> you need to hide.  
>> 
>> I interpret those sentences as identical to "Do not use Wireguard if
>> you live in a country where unlicensed VPN is illegal. Go and ask for
>> net neutrality instead." But the fact is that 2/3 of the world's
>> Internet users [2] live in censorship. For most of them, unlicensed
>> VPN is their only weapon to fight for net neutrality.
>> 
>> The undoubted top-1 encrypted proxy software [3] in China was not
>> written by a crypto professional and even started with RC4-MD5, not
>> until 5 years later (2017) did it have AEAD cipher.
>> 
>> People love Wireguard because of its security, flexibility and
>> efficiency, but only when it can work. It is useless to talk about
>> security if it does not work.
>> 
>> 
>> ## Can we solve the problem easily?
>> 
>> What makes Wireguard easy to detect?
>> - Fixed first 4 bytes
>>  (0x01000000 through 0x04000000)
>> - Plaintext nounce counter
>>  (Could XChaCha20 solve the problem?)
>> - Fixed sender & receiver ID
>>  (Two-pass encrypt might work, see below)
>> - Fixed length handshake & keep-alive
>>  (148, 92, 32. can we pad them longer?)
>> - Punctual rekey & keep-alive
>>  (Can we delay them randomly as IPsec do?)
>> 
>> How can we solve the problem?
>> - Embed steganography inside Wireguard?
>>  (Not realistic. Big codebase, potential bugs.)
>> - Two-pass encrypt so no more plaintext handshake?
>>  The outer layer could be PSK and does not need to be PFS.
>>  (Possible but slow. PSK can be shared among sessions, like
>> L2TP/IPsec do.)
>> - Remain plaintext, but fix padding and timing problem,
>>  relying Pluggable Transport [4] plugins to do the remaining work.
>>  (I really recommend this solution.)
>> 
>> I read the tech whitepaper multiple times. I think it is possible
>> solve the problem in Method 3 without breaking any compatibility. For
>> Message ID = 1, 2, 3, we can add random data at the end of the packet.
>> For Message ID = 4 and Length = 0 (keep-alive packet), we can add more
>> zeros in the encapsulated packet. For the timing problem, we can give
>> rekey and keep-alive a little bit randomness.
>> 
>> In conclusion, I think we do not need to break the compatibility or
>> bloat the code base to make Wireguard immune to being detected. We
>> could either two-pass encrypt the packet, or solve the padding and
>> timing problem so PT plugins can run on top of it. I hope to see
>> Wireguard run anywhere without worries, not only on devices owned by
>> 1/3 of the Internet's population.
>> 
>> 
>> ## Notes
>> 
>> [1] https://lists.zx2c4.com/pipermail/wireguard/2016-July/000184.html
>> [2] https://www.theverge.com/2016/11/14/13596974/
>> [3] https://github.com/shadowsocks/shadowsocks (Please switch git
>> branch to see the actual code)
>> [4]
>> https://www.torproject.org/docs/pluggable-transports.html.en#list-of-pts
>> 
>> 
>> Best regards.
>> _______________________________________________
>> WireGuard mailing list
>> WireGuard@lists.zx2c4.com
>> https://lists.zx2c4.com/mailman/listinfo/wireguard
> 
> 
> 
> -- 
> PGP Fingerprint: 5B93 F0B9 D6A8 9BC1 546B C98C 6105 A775 8CD2 46AC
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard

[-- Attachment #2: Type: text/html, Size: 17665 bytes --]

<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><blockquote type="cite"><font color="#000000"><span style="caret-color: rgb(0, 0, 0); background-color: rgba(255, 255, 255, 0);">The userspace daemon would:<br>&nbsp; &nbsp;- 'Clean' Wireguard [handshake/data] packets</span></font></blockquote><div><br></div><div>The objective of cleaning as described seems to be to make the protocol indistinguishable from exchanging random payloads. But are there any common protocols of commercial importance that are so inscrutable? If I saw such random-looking UDP payloads on the wire I would suspect malware c&amp;c, file sharing (who remembers FreeNet?), or a tunnel, depending on data volume and direction —nothing I would hesitate to block (or flag as suspicious) if I were running a big traffic classifier.</div><div><br></div><div>Domain fronting seems like the stealthiest option to me (and if anyone has a reliable way to detect domain fronting, I would love to hear about it!). But that doesn’t get you UDP (and NAT traversal); perhaps VOIP/WebRTC mimicry could work?</div><div><br></div><div><br></div><div>Best,</div><div>George</div><div><br></div><div><br></div><div id="AppleMailSignature">Sent from my iPhone</div><div><br>On Sep 6, 2018, at 4:43 AM, Dennis Jackson &lt;<a href="mailto:dennis.jackson@cs.ox.ac.uk">dennis.jackson@cs.ox.ac.uk</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><span>Hi, </span><br><span></span><br><span>I've been thinking about this issue as well and I agree it's an</span><br><span>important one to solve. However, Wireguard's key selling points are its</span><br><span>performance, simple configuration and minimal code size and I don't</span><br><span>think we can compromise this. So I was wondering if a userspace program</span><br><span>which obfuscates outgoing Wireguard packets and de-obfuscates incoming</span><br><span>packets might solve the problem, without impacting Wireguard's key</span><br><span>features. </span><br><span></span><br><span>The userspace daemon would:</span><br><span> &nbsp; &nbsp;- 'Clean' Wireguard handshake packets, </span><br><span> &nbsp; &nbsp; &nbsp; &nbsp;* Randomise the packet type field</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp;* Convert the ephemeral key to Elligator encoding</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp;* Randomise the mac field if unused</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp;* Random padding to alter packet lengths</span><br><span> &nbsp; &nbsp;- 'Clean' Data packets</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp;* The header is exactly 16 bytes and non-repeating so</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;transform with AES-ECB</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp;* The key could be derived from a PSK and the public</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;keys used in the handshake (ensuring keys don't</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;repeat)</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp;* Or Wireguard could provide a hook for a "post-master</span><br><span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;secret" which might be useful for many extensions</span><br><span> &nbsp; &nbsp;- The resulting stream would (hopefully) be uniformly</span><br><span> &nbsp; &nbsp; &nbsp;distributed which can either be transmitted directly or</span><br><span> &nbsp; &nbsp; &nbsp;passed to a pluggable transport. </span><br><span> &nbsp; &nbsp;- On the receiving end the daemon reverses the transformation</span><br><span> &nbsp; &nbsp; &nbsp;and delivers the packets to Wireguard.</span><br><span></span><br><span>Outcome:</span><br><span> &nbsp; &nbsp;+ Clear separation between codebases</span><br><span> &nbsp; &nbsp;+ No matter how badly implemented, the userspace daemon can't</span><br><span> &nbsp; &nbsp; &nbsp;compromise authenticity or confidentiality. </span><br><span> &nbsp; &nbsp;+ Easily extensible</span><br><span> &nbsp; &nbsp;+ Wireguard doesn't need to know about the transformation, it</span><br><span> &nbsp; &nbsp; &nbsp;just sends its packets to a listener on the loopback</span><br><span> &nbsp; &nbsp; &nbsp;interface.</span><br><span> &nbsp; &nbsp;- Performance hit from the packet indirection, ECB encryption</span><br><span> &nbsp; &nbsp; &nbsp;etc</span><br><span> &nbsp; &nbsp;- Still needs Wireguard to disable cookies, add timing jitter</span><br><span> &nbsp; &nbsp; &nbsp;on handshake / keep-alive packets. </span><br><span></span><br><span>I'm sure there are alternatives/better solutions. This is just a</span><br><span>sketch to show it is possible without altering Wireguard's codebase or</span><br><span>functionality. If you have any comments or criticism, I'd be interested</span><br><span>in refining the idea further. </span><br><span></span><br><span>Kind regards,</span><br><span>Dennis</span><br><span></span><br><span>On Thu, 6 Sep 2018 10:06:07 +1000</span><br><span>StarBrilliant &lt;<a href="mailto:coder@poorlab.com">coder@poorlab.com</a>&gt; wrote:</span><br><span></span><br><blockquote type="cite"><span>Hi,</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>(TL;DR: Please seriously consider preventing WG from being blocked,</span><br></blockquote><blockquote type="cite"><span>for 2/3 of the world's Internet users. No need to break compatibility,</span><br></blockquote><blockquote type="cite"><span>be friendly to PT plugins is a possible solution.)</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I have been using WG for months. I understand the fact that Wireguard</span><br></blockquote><blockquote type="cite"><span>wants to keep its protocol simple and easy to audit. I also understand</span><br></blockquote><blockquote type="cite"><span>that we have talked about this topic back in 2016. [1]</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>## The problem: way too easy to block</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I propose this issue again, because Wireguard has recently become a</span><br></blockquote><blockquote type="cite"><span>hot topic in Chinese community with the most strict</span><br></blockquote><blockquote type="cite"><span>&lt;del&gt;Internet&lt;/del&gt; Intranet censorship in the world. Chinese</span><br></blockquote><blockquote type="cite"><span>Wireguard users succeeded in access the Internet temporarily, but we</span><br></blockquote><blockquote type="cite"><span>know Wireguard never tries to prevent itself from being blocked.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>It is indeed very easy to completely block Wireguard protocol with</span><br></blockquote><blockquote type="cite"><span>iptables:</span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>iptables -A FORWARD -p udp -m length --length 120 -m u32 --u32 "0</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>22 &amp; 0x3c @ 8 = 0x2000000" -j DROP &nbsp;</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><span>(Yes, from prior experience of blocking TLS and OpenVPN, usually</span><br></blockquote><blockquote type="cite"><span>Message ID 2 is blocked instead of Message ID 1, probably for the</span><br></blockquote><blockquote type="cite"><span>intention to consume server resources.)</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>It is also possible to interfere with the keep-alive packet, since it</span><br></blockquote><blockquote type="cite"><span>is "always on time like a bus" and exactly 32 bytes:</span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>iptables -A FORWARD -p udp -m length --length 60 -m u32 --u32 "0 &gt;&gt;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>22 &amp; 0x3c @ 8 = 0x4000000" -m statistic --mode random --probability</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>0.4 -j DROP &nbsp;</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>## But it's unrelated to WG's security model!</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I heard someone saying something like below:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>On Sat Jul 9 17:49:47 CEST 2016, Bruno Wolff III &lt;<a href="mailto:bruno@wolff.to">bruno@wolff.to</a>&gt;</span><br></blockquote><blockquote type="cite"><span>wrote:</span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>Given the design goals of wireguard, I don't think it is something</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>that would be particularly good to combine with steganography. We</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>need real net neutrality, with ISPs not allowed to block traffic</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>based on content. We need governments not passing laws to make</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>people compromise their own security. Using strong unbreakable</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>encryption when communicating, should be the norm, not something</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>you need to hide. &nbsp;</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I interpret those sentences as identical to "Do not use Wireguard if</span><br></blockquote><blockquote type="cite"><span>you live in a country where unlicensed VPN is illegal. Go and ask for</span><br></blockquote><blockquote type="cite"><span>net neutrality instead." But the fact is that 2/3 of the world's</span><br></blockquote><blockquote type="cite"><span>Internet users [2] live in censorship. For most of them, unlicensed</span><br></blockquote><blockquote type="cite"><span>VPN is their only weapon to fight for net neutrality.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>The undoubted top-1 encrypted proxy software [3] in China was not</span><br></blockquote><blockquote type="cite"><span>written by a crypto professional and even started with RC4-MD5, not</span><br></blockquote><blockquote type="cite"><span>until 5 years later (2017) did it have AEAD cipher.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>People love Wireguard because of its security, flexibility and</span><br></blockquote><blockquote type="cite"><span>efficiency, but only when it can work. It is useless to talk about</span><br></blockquote><blockquote type="cite"><span>security if it does not work.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>## Can we solve the problem easily?</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>What makes Wireguard easy to detect?</span><br></blockquote><blockquote type="cite"><span>- Fixed first 4 bytes</span><br></blockquote><blockquote type="cite"><span> &nbsp;(0x01000000 through 0x04000000)</span><br></blockquote><blockquote type="cite"><span>- Plaintext nounce counter</span><br></blockquote><blockquote type="cite"><span> &nbsp;(Could XChaCha20 solve the problem?)</span><br></blockquote><blockquote type="cite"><span>- Fixed sender &amp; receiver ID</span><br></blockquote><blockquote type="cite"><span> &nbsp;(Two-pass encrypt might work, see below)</span><br></blockquote><blockquote type="cite"><span>- Fixed length handshake &amp; keep-alive</span><br></blockquote><blockquote type="cite"><span> &nbsp;(148, 92, 32. can we pad them longer?)</span><br></blockquote><blockquote type="cite"><span>- Punctual rekey &amp; keep-alive</span><br></blockquote><blockquote type="cite"><span> &nbsp;(Can we delay them randomly as IPsec do?)</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>How can we solve the problem?</span><br></blockquote><blockquote type="cite"><span>- Embed steganography inside Wireguard?</span><br></blockquote><blockquote type="cite"><span> &nbsp;(Not realistic. Big codebase, potential bugs.)</span><br></blockquote><blockquote type="cite"><span>- Two-pass encrypt so no more plaintext handshake?</span><br></blockquote><blockquote type="cite"><span> &nbsp;The outer layer could be PSK and does not need to be PFS.</span><br></blockquote><blockquote type="cite"><span> &nbsp;(Possible but slow. PSK can be shared among sessions, like</span><br></blockquote><blockquote type="cite"><span>L2TP/IPsec do.)</span><br></blockquote><blockquote type="cite"><span>- Remain plaintext, but fix padding and timing problem,</span><br></blockquote><blockquote type="cite"><span> &nbsp;relying Pluggable Transport [4] plugins to do the remaining work.</span><br></blockquote><blockquote type="cite"><span> &nbsp;(I really recommend this solution.)</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I read the tech whitepaper multiple times. I think it is possible</span><br></blockquote><blockquote type="cite"><span>solve the problem in Method 3 without breaking any compatibility. For</span><br></blockquote><blockquote type="cite"><span>Message ID = 1, 2, 3, we can add random data at the end of the packet.</span><br></blockquote><blockquote type="cite"><span>For Message ID = 4 and Length = 0 (keep-alive packet), we can add more</span><br></blockquote><blockquote type="cite"><span>zeros in the encapsulated packet. For the timing problem, we can give</span><br></blockquote><blockquote type="cite"><span>rekey and keep-alive a little bit randomness.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>In conclusion, I think we do not need to break the compatibility or</span><br></blockquote><blockquote type="cite"><span>bloat the code base to make Wireguard immune to being detected. We</span><br></blockquote><blockquote type="cite"><span>could either two-pass encrypt the packet, or solve the padding and</span><br></blockquote><blockquote type="cite"><span>timing problem so PT plugins can run on top of it. I hope to see</span><br></blockquote><blockquote type="cite"><span>Wireguard run anywhere without worries, not only on devices owned by</span><br></blockquote><blockquote type="cite"><span>1/3 of the Internet's population.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>## Notes</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>[1] <a href="https://lists.zx2c4.com/pipermail/wireguard/2016-July/000184.html">https://lists.zx2c4.com/pipermail/wireguard/2016-July/000184.html</a></span><br></blockquote><blockquote type="cite"><span>[2] <a href="https://www.theverge.com/2016/11/14/13596974/">https://www.theverge.com/2016/11/14/13596974/</a></span><br></blockquote><blockquote type="cite"><span>[3] <a href="https://github.com/shadowsocks/shadowsocks">https://github.com/shadowsocks/shadowsocks</a> (Please switch git</span><br></blockquote><blockquote type="cite"><span>branch to see the actual code)</span><br></blockquote><blockquote type="cite"><span>[4]</span><br></blockquote><blockquote type="cite"><span><a href="https://www.torproject.org/docs/pluggable-transports.html.en#list-of-pts">https://www.torproject.org/docs/pluggable-transports.html.en#list-of-pts</a></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Best regards.</span><br></blockquote><blockquote type="cite"><span>_______________________________________________</span><br></blockquote><blockquote type="cite"><span>WireGuard mailing list</span><br></blockquote><blockquote type="cite"><span><a href="mailto:WireGuard@lists.zx2c4.com">WireGuard@lists.zx2c4.com</a></span><br></blockquote><blockquote type="cite"><span><a href="https://lists.zx2c4.com/mailman/listinfo/wireguard">https://lists.zx2c4.com/mailman/listinfo/wireguard</a></span><br></blockquote><span></span><br><span></span><br><span></span><br><span>-- </span><br><span>PGP Fingerprint: 5B93 F0B9 D6A8 9BC1 546B C98C 6105 A775 8CD2 46AC</span><br></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>WireGuard mailing list</span><br><span><a href="mailto:WireGuard@lists.zx2c4.com">WireGuard@lists.zx2c4.com</a></span><br><span><a href="https://lists.zx2c4.com/mailman/listinfo/wireguard">https://lists.zx2c4.com/mailman/listinfo/wireguard</a></span><br></div></blockquote></body></html>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Let's talk about obfuscation again
  2018-09-06  0:06 StarBrilliant
@ 2018-09-06  8:43 ` Dennis Jackson
  2018-09-06 14:45   ` George Walker
  2018-09-06 16:10 ` Jason A. Donenfeld
  1 sibling, 1 reply; 9+ messages in thread
From: Dennis Jackson @ 2018-09-06  8:43 UTC (permalink / raw)
  To: wireguard

[-- Attachment #1: Type: text/plain, Size: 7357 bytes --]

Hi, 

I've been thinking about this issue as well and I agree it's an
important one to solve. However, Wireguard's key selling points are its
performance, simple configuration and minimal code size and I don't
think we can compromise this. So I was wondering if a userspace program
which obfuscates outgoing Wireguard packets and de-obfuscates incoming
packets might solve the problem, without impacting Wireguard's key
features. 

The userspace daemon would:
	- 'Clean' Wireguard handshake packets, 
		* Randomise the packet type field
		* Convert the ephemeral key to Elligator encoding
		* Randomise the mac field if unused
		* Random padding to alter packet lengths
	- 'Clean' Data packets
		* The header is exactly 16 bytes and non-repeating so
		  transform with AES-ECB
		* The key could be derived from a PSK and the public
		  keys used in the handshake (ensuring keys don't
		  repeat)
		* Or Wireguard could provide a hook for a "post-master
		  secret" which might be useful for many extensions
	- The resulting stream would (hopefully) be uniformly
	  distributed which can either be transmitted directly or
	  passed to a pluggable transport. 
	- On the receiving end the daemon reverses the transformation
	  and delivers the packets to Wireguard.

Outcome:
	+ Clear separation between codebases
	+ No matter how badly implemented, the userspace daemon can't
	  compromise authenticity or confidentiality. 
	+ Easily extensible
	+ Wireguard doesn't need to know about the transformation, it
	  just sends its packets to a listener on the loopback
	  interface.
	- Performance hit from the packet indirection, ECB encryption
	  etc
	- Still needs Wireguard to disable cookies, add timing jitter
	  on handshake / keep-alive packets. 

I'm sure there are alternatives/better solutions. This is just a
sketch to show it is possible without altering Wireguard's codebase or
functionality. If you have any comments or criticism, I'd be interested
in refining the idea further. 

Kind regards,
Dennis

On Thu, 6 Sep 2018 10:06:07 +1000
StarBrilliant <coder@poorlab.com> wrote:

> Hi,
> 
> (TL;DR: Please seriously consider preventing WG from being blocked,
> for 2/3 of the world's Internet users. No need to break compatibility,
> be friendly to PT plugins is a possible solution.)
> 
> I have been using WG for months. I understand the fact that Wireguard
> wants to keep its protocol simple and easy to audit. I also understand
> that we have talked about this topic back in 2016. [1]
> 
> 
> ## The problem: way too easy to block
> 
> I propose this issue again, because Wireguard has recently become a
> hot topic in Chinese community with the most strict
> <del>Internet</del> Intranet censorship in the world. Chinese
> Wireguard users succeeded in access the Internet temporarily, but we
> know Wireguard never tries to prevent itself from being blocked.
> 
> It is indeed very easy to completely block Wireguard protocol with
> iptables:
> > iptables -A FORWARD -p udp -m length --length 120 -m u32 --u32 "0
> > >> 22 & 0x3c @ 8 = 0x2000000" -j DROP  
> (Yes, from prior experience of blocking TLS and OpenVPN, usually
> Message ID 2 is blocked instead of Message ID 1, probably for the
> intention to consume server resources.)
> 
> It is also possible to interfere with the keep-alive packet, since it
> is "always on time like a bus" and exactly 32 bytes:
> > iptables -A FORWARD -p udp -m length --length 60 -m u32 --u32 "0 >>
> > 22 & 0x3c @ 8 = 0x4000000" -m statistic --mode random --probability
> > 0.4 -j DROP  
> 
> 
> ## But it's unrelated to WG's security model!
> 
> I heard someone saying something like below:
> 
> On Sat Jul 9 17:49:47 CEST 2016, Bruno Wolff III <bruno@wolff.to>
> wrote:
> > Given the design goals of wireguard, I don't think it is something
> > that would be particularly good to combine with steganography. We
> > need real net neutrality, with ISPs not allowed to block traffic
> > based on content. We need governments not passing laws to make
> > people compromise their own security. Using strong unbreakable
> > encryption when communicating, should be the norm, not something
> > you need to hide.  
> 
> I interpret those sentences as identical to "Do not use Wireguard if
> you live in a country where unlicensed VPN is illegal. Go and ask for
> net neutrality instead." But the fact is that 2/3 of the world's
> Internet users [2] live in censorship. For most of them, unlicensed
> VPN is their only weapon to fight for net neutrality.
> 
> The undoubted top-1 encrypted proxy software [3] in China was not
> written by a crypto professional and even started with RC4-MD5, not
> until 5 years later (2017) did it have AEAD cipher.
> 
> People love Wireguard because of its security, flexibility and
> efficiency, but only when it can work. It is useless to talk about
> security if it does not work.
> 
> 
> ## Can we solve the problem easily?
> 
> What makes Wireguard easy to detect?
> - Fixed first 4 bytes
>   (0x01000000 through 0x04000000)
> - Plaintext nounce counter
>   (Could XChaCha20 solve the problem?)
> - Fixed sender & receiver ID
>   (Two-pass encrypt might work, see below)
> - Fixed length handshake & keep-alive
>   (148, 92, 32. can we pad them longer?)
> - Punctual rekey & keep-alive
>   (Can we delay them randomly as IPsec do?)
> 
> How can we solve the problem?
> - Embed steganography inside Wireguard?
>   (Not realistic. Big codebase, potential bugs.)
> - Two-pass encrypt so no more plaintext handshake?
>   The outer layer could be PSK and does not need to be PFS.
>   (Possible but slow. PSK can be shared among sessions, like
> L2TP/IPsec do.)
> - Remain plaintext, but fix padding and timing problem,
>   relying Pluggable Transport [4] plugins to do the remaining work.
>   (I really recommend this solution.)
> 
> I read the tech whitepaper multiple times. I think it is possible
> solve the problem in Method 3 without breaking any compatibility. For
> Message ID = 1, 2, 3, we can add random data at the end of the packet.
> For Message ID = 4 and Length = 0 (keep-alive packet), we can add more
> zeros in the encapsulated packet. For the timing problem, we can give
> rekey and keep-alive a little bit randomness.
> 
> In conclusion, I think we do not need to break the compatibility or
> bloat the code base to make Wireguard immune to being detected. We
> could either two-pass encrypt the packet, or solve the padding and
> timing problem so PT plugins can run on top of it. I hope to see
> Wireguard run anywhere without worries, not only on devices owned by
> 1/3 of the Internet's population.
> 
> 
> ## Notes
> 
> [1] https://lists.zx2c4.com/pipermail/wireguard/2016-July/000184.html
> [2] https://www.theverge.com/2016/11/14/13596974/
> [3] https://github.com/shadowsocks/shadowsocks (Please switch git
> branch to see the actual code)
> [4]
> https://www.torproject.org/docs/pluggable-transports.html.en#list-of-pts
> 
> 
> Best regards.
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard



-- 
PGP Fingerprint: 5B93 F0B9 D6A8 9BC1 546B C98C 6105 A775 8CD2 46AC

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Let's talk about obfuscation again
@ 2018-09-06  0:06 StarBrilliant
  2018-09-06  8:43 ` Dennis Jackson
  2018-09-06 16:10 ` Jason A. Donenfeld
  0 siblings, 2 replies; 9+ messages in thread
From: StarBrilliant @ 2018-09-06  0:06 UTC (permalink / raw)
  To: wireguard

Hi,

(TL;DR: Please seriously consider preventing WG from being blocked,
for 2/3 of the world's Internet users. No need to break compatibility,
be friendly to PT plugins is a possible solution.)

I have been using WG for months. I understand the fact that Wireguard
wants to keep its protocol simple and easy to audit. I also understand
that we have talked about this topic back in 2016. [1]


## The problem: way too easy to block

I propose this issue again, because Wireguard has recently become a
hot topic in Chinese community with the most strict
<del>Internet</del> Intranet censorship in the world. Chinese
Wireguard users succeeded in access the Internet temporarily, but we
know Wireguard never tries to prevent itself from being blocked.

It is indeed very easy to completely block Wireguard protocol with iptables:
> iptables -A FORWARD -p udp -m length --length 120 -m u32 --u32 "0 >> 22 & 0x3c @ 8 = 0x2000000" -j DROP
(Yes, from prior experience of blocking TLS and OpenVPN, usually
Message ID 2 is blocked instead of Message ID 1, probably for the
intention to consume server resources.)

It is also possible to interfere with the keep-alive packet, since it
is "always on time like a bus" and exactly 32 bytes:
> iptables -A FORWARD -p udp -m length --length 60 -m u32 --u32 "0 >> 22 & 0x3c @ 8 = 0x4000000" -m statistic --mode random --probability 0.4 -j DROP


## But it's unrelated to WG's security model!

I heard someone saying something like below:

On Sat Jul 9 17:49:47 CEST 2016, Bruno Wolff III <bruno@wolff.to> wrote:
> Given the design goals of wireguard, I don't think it is something that would be particularly good to combine with steganography.
> We need real net neutrality, with ISPs not allowed to block traffic based on content.
> We need governments not passing laws to make people compromise their own security.
> Using strong unbreakable encryption when communicating, should be the norm, not something you need to hide.

I interpret those sentences as identical to "Do not use Wireguard if
you live in a country where unlicensed VPN is illegal. Go and ask for
net neutrality instead." But the fact is that 2/3 of the world's
Internet users [2] live in censorship. For most of them, unlicensed
VPN is their only weapon to fight for net neutrality.

The undoubted top-1 encrypted proxy software [3] in China was not
written by a crypto professional and even started with RC4-MD5, not
until 5 years later (2017) did it have AEAD cipher.

People love Wireguard because of its security, flexibility and
efficiency, but only when it can work. It is useless to talk about
security if it does not work.


## Can we solve the problem easily?

What makes Wireguard easy to detect?
- Fixed first 4 bytes
  (0x01000000 through 0x04000000)
- Plaintext nounce counter
  (Could XChaCha20 solve the problem?)
- Fixed sender & receiver ID
  (Two-pass encrypt might work, see below)
- Fixed length handshake & keep-alive
  (148, 92, 32. can we pad them longer?)
- Punctual rekey & keep-alive
  (Can we delay them randomly as IPsec do?)

How can we solve the problem?
- Embed steganography inside Wireguard?
  (Not realistic. Big codebase, potential bugs.)
- Two-pass encrypt so no more plaintext handshake?
  The outer layer could be PSK and does not need to be PFS.
  (Possible but slow. PSK can be shared among sessions, like L2TP/IPsec do.)
- Remain plaintext, but fix padding and timing problem,
  relying Pluggable Transport [4] plugins to do the remaining work.
  (I really recommend this solution.)

I read the tech whitepaper multiple times. I think it is possible
solve the problem in Method 3 without breaking any compatibility. For
Message ID = 1, 2, 3, we can add random data at the end of the packet.
For Message ID = 4 and Length = 0 (keep-alive packet), we can add more
zeros in the encapsulated packet. For the timing problem, we can give
rekey and keep-alive a little bit randomness.

In conclusion, I think we do not need to break the compatibility or
bloat the code base to make Wireguard immune to being detected. We
could either two-pass encrypt the packet, or solve the padding and
timing problem so PT plugins can run on top of it. I hope to see
Wireguard run anywhere without worries, not only on devices owned by
1/3 of the Internet's population.


## Notes

[1] https://lists.zx2c4.com/pipermail/wireguard/2016-July/000184.html
[2] https://www.theverge.com/2016/11/14/13596974/
[3] https://github.com/shadowsocks/shadowsocks (Please switch git branch to see
    the actual code)
[4] https://www.torproject.org/docs/pluggable-transports.html.en#list-of-pts


Best regards.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1542.1536245115.2201.wireguard@lists.zx2c4.com>
2018-09-06 15:24 ` Let's talk about obfuscation again Brian Candler
2018-09-06 21:16   ` James Cloos
2018-09-06  0:06 StarBrilliant
2018-09-06  8:43 ` Dennis Jackson
2018-09-06 14:45   ` George Walker
2018-09-06 15:19     ` Fredrik Strömberg
2018-09-07  8:49       ` StarBrilliant
2018-09-06 15:34     ` Dennis Jackson
2018-09-06 16:10 ` Jason A. Donenfeld

WireGuard Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/wireguard/0 wireguard/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 wireguard wireguard/ https://lore.kernel.org/wireguard \
		wireguard@lists.zx2c4.com zx2c4-wireguard@archiver.kernel.org
	public-inbox-index wireguard


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/com.zx2c4.lists.wireguard


AGPL code for this site: git clone https://public-inbox.org/ public-inbox