Giter VIP home page Giter VIP logo

wire-avs's Introduction

Wire - Audio, Video, and Signaling (AVS)

This repository is part of the source code of Wire. You can find more information at wire.com or by contacting [email protected].

You can find the published source code at github.com/wireapp.

For licensing information, see the attached LICENSE file and the list of third-party licenses at wire.com/legal/licenses/.

Build Requirements

Apart from the basic toolchain for each system, you need these:

  • clang, libc++
  • readline (for building zcall, only)
  • yasm (for video only)
  • alsa (for Linux only).

For OSX and iOS, you should have Xcode and the Command Line Tools for your specific version of both OSX and Xcode. Things will break if you have the wrong version. You can install the latter via menu Xcode, then Open Developer Tool, then More Developer Tools.

For getting autoconf, automake, libtool, readline and yasm, we suggest Homebrew. Follow the instructions there, then:

$ brew install \
  autoconf \
  automake \
  jq \
  libsodium \
  libtool \
  rust \
  pkg-config \
  protobuf-c \
  readline

For Android, you need both the Android SDK as well as the Android NDK. Just get the latest versions and install them somewhere cozy. You need to export two environment variables ANDROID_SDK_ROOT and ANDROID_NDK_ROOT pointing to the respective location. Unless you do a one-off, you probably want to add them to your .bash_profile.

For Linux, you need to install the packages for the stuff mentioned above or, of course, build it all from scratch. If you are on a Debian-esque system, do this:

$ sudo apt-get install \
  autoconf \
  automake \
  clang \
  libasound2-dev \
  libc++-dev \
  libc++abi-dev \
  libevent-dev \
  libprotobuf-c-dev \
  libreadline-dev \
  libsodium-dev \
  libtool \
  libx11-dev \
  libxcomposite-dev \
  libxdamage-dev \
  libxrender-dev \
  make \
  pkgconf \
  protobuf-c-compiler \
  yasm \
  zlib1g-dev \
  zip

$ curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly

For Windows, you will have to start by adding your system to the build system. Good luck!

Build Instructions

AVS uses pre-built Google WebRTC by default that are pulled from the prebuilt webrtc repository as a part of the make process. For information about building your own WebRTC see the "Using a Locally Built WebRTC" section below.

AVS has more dependencies that need to be updated. The first time you need to fetch the submodules by doing:

$ ./prepare.sh

Next step is to build AVS itself. When building AVS with the prebuilt WebRTC, invoke make with:

make

This will build a selection of tools or your host machine. You probably want zcall, the AVS command line client. You can only build that by saying make zcall. Similarly, you can build any other tool by giving its name to make.

The deliverables are being built with the command make dist. You can limit this to only select target platforms through make dist_android, make dist_osx and make dist_ios. All of them take quite a while on a fresh checkout.

You'll find the deliverables in build/dist/{android,ios,osx}.

You can also build just the wrappers for a given architecture by saying make wrappers AVS_OS=<os> AVS_ARCH=<arch> where <os> is one of android, ios, or osx. There is no wrappers for Linux, so you are out of luck there. For <arch> there are several possible values depending on the OS. You can just leave the whole thing out and will receive reasonable defaults (ARMv7 or X86-64). Have a look at mk/target.mk for more on this.

If you want to have a local version of a dist_* target that hasn't all the necessary architectures but builds quicker, you can pass DIST_ARCH=<your_arch> to make and will only built for that architecture:

$ make dist_ios DIST_ARCH=arm64

will build an iOS distribution that will only contain arm64 instead of the usual five architectures.

Using a Locally Built WebRTC

It is possible to use your own locally built WebRTC libraries instead, by following the instructions in the readme file of the prebuilt webrtc repository.

Once built and packaged you should have the following files:

contrib/webrtc/webrtc_<version>_android.zip
contrib/webrtc/webrtc_<version>_headers.zip
contrib/webrtc/webrtc_<version>_ios.zip
contrib/webrtc/webrtc_<version>_linux.zip
contrib/webrtc/webrtc_<version>_osx.zip

These files should be copied to the contrib/webrtc directory and the WEBRTC_VER variable set when making AVS, for example:

make WEBRTC_VER=20200603.local

You can also modify the version set in the mk/target.mk file, as follows:

ifeq ($(WEBRTC_VER),)
WEBRTC_VER := 20200603.local
endif

Running make should then unpack and use the locally built version of WebRTC.

Using the Library

During the build, a set of static libraries is being built. You can use this library in your own projects.

You'll find the APIs in include/*.h. avs.h is your catchall include file. Always use that to protect yourself agains reorganizations.

Linking is a bit tricky, we'll add instructions soon. The easiest is probably to add build/$(your-platform)/lib to your library path and then add all .a files in there as -l arguments.

Using the Command Line Client (zcall)

Start the command line client provding the email address of an existing account using the -e option. You can switch to staging (aka dev) by adding the -D option and to edge by adding the -E option. Since caching is currently a little broken, you probably want to add the -f option, too. For further information on available options, try the ever helpful -h option.

Once started, hit h to see a list of key strokes available and type :help and enter to see a list of commands. All commands are entered by typing : first.

Creating a Client

The first thing you will need is a clientid. This can be done as follows:

:get_clients lists clients for this user, the current one for zcall is marked with a * :reg_client register a new client

There is a limit of 8 clients per user, if all are used you will need to remove one with:

:delete_cient <clientid>

Beware that there is no "are you sure" question, use this only if you know what you are doing! If you delete an in-use client by accident bad things may happen.

Managing Conversations

Keys for listing, selecting and showing conversations are:

l list conversations, the selected one is marked with -> j select previous conversation k select next conversation i show selected conversation ID and members

You can also select a conversation with the :switch command and send basic chat messages to the selected conversation with :say

Calling

Keys for calling are:

c start a call in the selected conversation a answer the most recent incoming call e end/leave the call m toggle mute V toggle video sending

Incoming calls are indicated by the following line:

calling: incoming audio call in conv: Conversation (conference) from "test_user:0123456789abcdef" ring: yes ts: 1614244695

Architecture overview:

           .-----------.                            .---------.  .----------.
           |   wcall   |                            | engine  |  | mediamgr |
           '-----------'                            '---------'  '----------'
            /    |    \                                  |
  .-----------.  |  .-----------.   .----------.    .---------.
  |  egcall   |  |  |   ccall   |---| keystore |    |  REST   |
  '-----------'  |  '-----------'   '----------'    |  nevent |
            \    |    /                             | protobuf|
           .-----------.   .-----------.            '---------'
           |   ecall   |---|  econn    |
           '-----------'   '-----------'
             /        \
     mobile /          \ web
  .-----------.     .-----------.
  | peerflow  |     |  jsflow   |
  '-----------'     '-----------'
        |                 |
  .-----------.     .-----------.
  |webrtc(C++)|     | avs_pc(JS)|
  | peerconn  |     '-----------'
  '-----------'           |
                    .-----------.
                    | webrtc(JS)|
                    | peerconn  |
                    '-----------'

    .------------------------------.
    | Low-level utility modules:   |
    | - audummy (Dummy audio-mod)  |
    | - base (Base module)         |
    | - cert (Certificates)        |
    | - dict (Dictionary)          |
    | - jzon (Json wrappers)       |
    | - log (Logging framework)    |
    | - queue (Packet queue)       |
    | - sem (Semaphores)           |
    | - store (Persistent Storage) |
    | - trace (Tracing tool)       |
    | - uuid (UUID helpers)        |
    | - zapi (ZETA-protocol API)   |
    | - ztime (Timestamp helpers)  |
    '------------------------------'

Some specifications implemented:

Reporting bugs

When reporting bugs against AVS please include the following:

  • Wireshark PCAP trace (download Wireshark)
  • Full logs from client
  • Session-ID
  • Which Backend was used
  • Exact version of client
  • Exact time when call was started/stopped
  • Name/OS of device
  • Adb logcat for Android

Run-time libraries

FROM ubuntu:16.04 RUN apt-get install -qqy --no-install-recommends
libprotobuf-c-dev
libc6-dev-i386
libreadline-dev
libx11-dev
libxcomposite-dev
libxdamage-dev
libxrender-dev
libc++-dev
libc++abi-dev

Upload to sonatype

To manually upload to sonatype create a local.properties with the following values:

sonatype.username=
sonatype.password=
signingKeyFile=<path to asc file>
signingPassword=<gpg key passphrase>

wire-avs's People

Contributors

alfredhz avatar c-g-owen avatar comawill avatar dependabot[bot] avatar lipis avatar mythsunwind avatar raphaelrobert avatar typfel avatar z-dule avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wire-avs's Issues

Git submodule is not fetching contrib/re...

steven@stevens-MBP WireAVS % git submodule init
steven@stevens-MBP WireAVS % git submodule update
steven@stevens-MBP WireAVS % git submodule foreach git fetch
Entering 'contrib/cryptobox-c'
Entering 'contrib/generic-message-proto'
Entering 'contrib/googletest'
Entering 'contrib/rem'
Entering 'contrib/rew'
Entering 'contrib/sodium'

There is no contrib/re.
The contrib/re files are missing during final make command.
But I can git clone 're' manually into contrib folder and everything works fine.
Please fix the submodule config.

Complexity and Lack of Protection of Code

I create this issue to represent the web front-end concerns written up at https://crysp.uwaterloo.ca/opinion/wire/ .

The Wire implementation is extremely complex, making the attack surface relatively large. The desktop application is implemented as a packaged web application. Each time that the application is launched, large parts of the code (written in JavaScript) are re-downloaded and executed from the Wire servers without user interaction. Essentially, the Wire app itself is merely an embedded web browser. There does not appear to be any notion of "JavaScript pinning".

A common weakness of all secure messaging applications is that the application must be downloaded, trusted, and updated regularly; if the update mechanism is ever compromised, the system can be made to arbitrarily deviate from the specifications to the benefit of the attacker. However, the current design of the Wire desktop application makes such attacks simple, difficult to detect, and rapid. Moreover, the complexity of the application and its libraries presents many opportunities for security vulnerabilities. While this complexity may be necessary to support the rich feature integrations of the platform and the broad system support, the cost is more opportunity for exploitation.

Homebrew is not able to install multirust on Mac

There is no such dependency on home-brew( or it has been removed):

brew info multirust
Error: No available formula with the name "multirust"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.

When I tried to build multirust from source it failed on fetching one of its submodule:

git clone --depth=1 https://github.com/brson/multirust && cd multirust
...
git submodule update --init --recursive
fatal: not a git repository (or any of the parent directories): .git
newrock@ZhaodeMac-mini GitProject % cd multirust
newrock@ZhaodeMac-mini multirust % git submodule update --init --recursive
error: Server does not allow request for unadvertised object aa5ffc99caf4864b2928bc5d5be37c483ab0eba0
Fetched in submodule path 'src/rustup', but it did not contain aa5ffc99caf4864b2928bc5d5be37c483ab0eba0. Direct fetching of that commit failed.

And the README says it has migrated to rustup.rs

Any ideas to make it work? Thanks in advance.

Server is Closed-Source

This issue is mentioned at https://crysp.uwaterloo.ca/opinion/wire/ , a review of Wire by a security researcher.

The Wire client is open source—and open to analysis by security researchers—but the server software is not.

Notably, close-sourcing the server means that if anything happens to Wire Swiss, the ecosystem of Wire users dies with it. Nobody can spin up their own server and keep things running into the future. And of course, the server may have security vulnerabilities that nobody can safely check for, because the code is unavailable.

This repository is outdated and incompatible with wireapp-android

The code in this repository (version 3.4) is outdated and no longer API compatible to ZMessaging
https://github.com/wireapp/wire-android-sync-engine/tree/108.0 or later.

The current wireapp-android requires at least ZMessaging version 112, which requires API features only present in AVS version 3.6 or later.

native calls not present but required are, among others:
wcall_config_update()
wcall_create()
...

wireapp-android can be built against AVS version 3.4 but will crash at runtime when attempting to call these from ZMessaging

Format String Vulnerability

Format String Vulnerability

There is a Format String vulnerability in sdp.cpp line 99.

https://github.com/wireapp/wire-audio-video-signaling/blob/6bd9e51730a80cf527f7f30d7f8d6853fb2d875d/src/peerflow/sdp.c#L99

The function parameter value of function sdp_media_set_lattr() is controllable by an attacker and can lead to a format string attack. The function sdp_media_set_lattr() is implemented in media.c of the library re.

The vulnerability is fixed in current Android and iOS Wire Applications.

The vulnerability was exploitable in the Android and iOS Wire Apps at least until Wire Android Version 3.46.890 and iOS Version 3.58. An attacker could crash remote Wire Applications by a call with malformed sdp data, if the remote particpant accepted the call. The vulnerability could potentially lead to remote code execution.

AVS Release 5.3(arm64 ndk build failed)

make WEBRTC_VER=72.local dist_android
armv7 is ok:
[armeabi-v7a] Compile++ thumb: avs <= flow_manager.cc
[armeabi-v7a] Compile++ thumb: avs <= media_manager.cc
[armeabi-v7a] Compile++ thumb: avs <= video_renderer.cc
[armeabi-v7a] Compile++ thumb: avs <= audio_effect.cc
[armeabi-v7a] SharedLibrary : libavs.so
[armeabi-v7a] Install : libavs.so => libs/armeabi-v7a/libavs.so

But arm64 is failed:
......

/home/ryan/wire-audio-video-signaling/build/toolchains/android-arm64/ndk/ndk-build -C android -I ../build/android-arm64
Android NDK: WARNING: APP_PLATFORM android-21 is higher than android:minSdkVersion 1 in ./AndroidManifest.xml. NDK binaries will not be comptible with devices older than android-21. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
Android NDK: WARNING:jni/Android.mk:avs: non-system libraries in linker flags: -lavscore -lre -lrew -lsodium -lwebrtc -lc++_static -lc++abi
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module

make[1]: Entering directory `/home/ryan/wire-audio-video-signaling/android'
[arm64-v8a] Compile++ : avs <= flow_manager.cc
[arm64-v8a] Compile++ : avs <= media_manager.cc
[arm64-v8a] Compile++ : avs <= video_renderer.cc
[arm64-v8a] Compile++ : avs <= audio_effect.cc
[arm64-v8a] SharedLibrary : libavs.so

/home/ryan/devtools/android-ndk-r16b/build/../sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_static.a(locale.o): In function float std::__ndk1::__do_strtod<float>(char const*, char**)': /usr/local/google/buildbot/src/android/ndk-release-r16/external/libcxx/include/locale:807: undefined reference to strtof_l'
/home/ryan/devtools/android-ndk-r16b/build/../sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_static.a(locale.o): In function double std::__ndk1::__do_strtod<double>(char const*, char**)': /usr/local/google/buildbot/src/android/ndk-release-r16/external/libcxx/include/locale:813: undefined reference to strtod_l'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [obj/local/arm64-v8a/libavs.so] Error 1
make[1]: Leaving directory `/home/ryan/wire-audio-video-signaling/android'
mk/dist.mk:149: recipe for target '/home/ryan/wire-audio-video-signaling/build/dist/android/avs.aar' failed
make: *** [/home/ryan/wire-audio-video-signaling/build/dist/android/avs.aar] Error 2

I had try NDK r16b 、r17、r18、r19、r20. All are same error.
I don't know how to solve this problem. who can help me? thanks.

The lack of file?

wire-audio-video-signaling-master\mediaengine\webrtc There is no file?

Missing zcall client code

I am looking to get started with the AVS code base but I note the zcall command line utility which would have made a good stating point to understand how to work with the code appears to be missing from the repository. It is described in the README.md so I believe that this is something that should exist?

Handle partial messages in data channels

I've had a glance at your code and it seems you're not handling the MSG_EOR flag which means you will treat incoming partial SCTP messages as whole messages, thus violating the message-oriented principle of SCTP (and data channels). This is a widespread issue in many implementations we're currently trying to clean up.

If you need help, you can look at the relevant section in RAWRTC's code or at Mozilla's implementation. I'm the author of RAWRTC and I've also worked on Mozilla's data channel code, so feel free to ping me if you have any questions.

Tracked (and resolved) for Firefox in bug 979417. For Chromium, this is tracked in issue 7774.

How to use?

Hello, I want to integrate into my project, I hava turn/sturn server, but how can I use this library, does someone give an example code or document? Thanks a lot.

Submodule perhaps not pushed ?

I just tried to build on linux x86 and got :
./prepare.sh
fatal: reference is not a tree: a7facf0cd496e8952e355e72af755686024567fc
Unable to checkout 'a7facf0cd496e8952e355e72af755686024567fc' in submodule path 'contrib/generic-message-proto'

Stack overflow seems to say this means that the generic-message-proto submodule references a local version that hasn't yet been pushed.

Authentication: Man-In-The-Middle Vulnerability

I create this issue to represent the call authentication security concerns written up at https://crysp.uwaterloo.ca/opinion/wire/ .

When securing a conversation, confidentiality (hiding the contents of the conversation) is not the only desirable property. Without also authenticating the conversation, an attacker located in the network (e.g., a malicious actor intercepting traffic on a user's LAN, or a compromised ISP) can insert themselves between the endpoints. Wire provides both properties for text-based conversations.

The Wire protocol uses SRTP to secure audio/video calls. SRTP requires an external mechanism to establish the initial cryptographic key to protect the data. Wire uses a DTLS handshake to establish this initial key. DTLS is a UDP-based analog of TLS (used to secure HTTPS web browsing). Consequently, the key exchange in a DTLS handshake needs to be authenticated by a certificate authority, as in the case of web certificates. Based on some quick packet captures, it appears that the certificates used by Wire for this DTLS handshake are self-signed. If this is truly the case, then the handshakes do not provide any authentication in the presence of an active network attacker (i.e., a network attacker that can modify traffic), making Wire audio/video calls vulnerable to man-in-the-middle attacks.

The Wire security whitepaper says that "the authenticity of the clients is also verified during the handshake", but this is not consistent with the use of self-signed DTLS certificates. If the certificates are authenticated by the central Wire servers, then this prevents call interception by anyone except for the Wire operators.

In either case, the use of DTLS here is highly unusual and the security it provides is sub-optimal. A better approach would be to use a protocol like ZRTP (the standard used by Signal, Jitsi, Linphone, and others) to establish the initial SRTP key, or perhaps a more advanced key exchange scheme. The authentication for this scheme should not be based on certificates (as in DTLS); instead, the authentication should be bound to the long-term keys that are used by Wire's text-based conversations. A very simple solution would be to transparently perform a well-known unauthenticated key exchange (e.g., Diffie-Hellman) over an authenticated Wire text conversation, and to use the resulting key to initiate SRTP for the audio/video call.

The Wire security whitepaper mentions that authenticating audio/video calls against the cryptographic identities used for the text messaging protocol is future work, so this issue appears to be known.

engine_fetch_asset() and engine_send_file() failed when in group chat

When in a group chat and a file is sent to the group, the following code snippet fails (400) to work:

        case GENERIC_MESSAGE__CONTENT_ASSET:
            struct Asset *asset;
            struct Asset__Original *ao;
            Asset__RemoteData *ar;
            asset = gm->asset;
            ao = asset->original;
            ar = asset->uploaded;

            engine_fetch_asset(zcall_engine, conv->id, ar->asset_id, "/tmp/");

Also, while in a group chat, calling engine_send_file using for example: engine_send_file(conv, "image/jpeg", "/tmp/x.jpg"); also fails (404).

Ensure Use of Constant-Bitrate Codecs

I create this issue to represent the codec size concerns written up at https://crysp.uwaterloo.ca/opinion/wire/ .

It has been known for some time (e.g., WMM06, WBMM07, and WMSM11) within the system security academic community that using variable-bitrate codecs within an encrypted tunnel leaks information about the communication. Since encryption does not hide the length of the messages being transmitted, the bitrate of a conversation over time can be observed by a passive network attacker, even without access to the encryption keys in use. In some cases, knowledge of the bitrate changes is sufficient to reconstruct the unencrypted conversation with high accuracy. Consequently, while variable-bitrate codecs use the available bandwidth more efficiently, using constant-bitrate codecs is important for security.

The security whitepaper mentions that Wire uses the Opus codec to transmit audio data. The whitepaper does not mention what codec is used for video data. Opus supports both variable- and constant-bitrate encodings, so it is unclear if Wire is vulnerable to traffic analysis. In any case, Wire should ensure that constant-bitrate codecs are used for both audio and video data, and that this is clearly stated in the security whitepaper.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.