Giter VIP home page Giter VIP logo

raycxggg / blueswat Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 42.4 MB

Artifact for BlueSWAT, A Lightweight State-Aware Security Framework for Bluetooth Low Energy (To appear in CCS 2024).

CMake 1.84% C 91.48% C++ 0.14% Makefile 0.04% Shell 0.25% Assembly 0.98% Python 4.53% Tcl 0.01% CSS 0.01% HTML 0.01% JavaScript 0.01% Smalltalk 0.01% Perl 0.55% SmPL 0.05% EmberScript 0.01% Haskell 0.01% Verilog 0.02% FreeBasic 0.01% Batchfile 0.01% Ruby 0.07%

blueswat's Introduction

BlueSWAT: A Lightweight State-Aware Security Framework for Bluetooth Low Energy

This repository contains the artifact for BlueSWAT, a Bluetooth security framework for IoT devices based on eBPF. For more information about BlueSWAT, please check out our paper "BlueSWAT: A Lightweight State-Aware Security Framework for Bluetooth Low Energy" (To appear in CCS 2024).

Table for Artifact Evaluation

  1. Requirements.
  2. Set up ZephyrOS and Nordic 52840 Development Kit.
  3. Defense capability.
  4. Memory consumption.
  5. Runtime latency.
  6. Power assess.

0. Requirements

Software

  • Ubuntu 20.04 or WSL2.
  • Segger JLINK.
  • A mobile BLE app, e.g., nRF Connect, BLEscanner.

Hardware

  • Victim: Nordic 52840 Development Kit.
  • Attacker: Nordic 52840 Dongle.
  • A power assess tool, e.g., ChargerLAB POWER-Z KT002.

1. Environment Setup

BlueSWAT is tested under Ubuntu 20.04 on WSL2. This artifact contains implementation on two embedded OS with open-source BLE stacks, i.e., ZephyrOS and MynewtOS. For artifact evaluation, we introduce the testing procedure for ZephyrOS.

To flash USB device from WSL2, please install usbipd. Besides, install the Segger JLINK Software and documentation pack.

Download the source code:

git clone https://github.com/RayCxggg/BlueSWAT.git

In a Windows shell, connect the board and attach it to WSL2:

usbipd list 
usbipd bind --busid <busid>
usbipd attach --wsl --busid <busid>

Set up Zephyr BLE stack

Please follow STEP ONE and TWO in the doc to install dependencies.

Install required Python packages:

pip3 install --user -r ~/BlueSWAT/ZephyrOS/zephyr/scripts/requirements.txt

Install Zephyr Software Development Toolchain:

cd ~
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.11.2/zephyr-sdk-0.11.2-setup.run
chmod +x zephyr-sdk-0.11.2-setup.run
./zephyr-sdk-0.11.2-setup.run -- -d ~/SDK/zephyr-sdk-0.11.2
rm zephyr-sdk-0.11.2-setup.run

Clone required remote repositories:

cd BlueSWAT/ZephyrOS/zephyr
west update

Set build environment variables:

cd BlueSWAT/ZephyrOS/zephyr
source zephyr-env.sh

BlueSWAT is added a subsystem of the kernel and locates at ZephyrOS/zephyr/firewall.

Build and Flash

Now, we build the BLE peripheral application for Nordic 52840 DK:

cd BlueSWAT/ZephyrOS
source scripts/config.sh
source scripts/build.sh

Everything is settled! Flash the board:

source scripts/flash.sh

After flashing the firmware, press the RESET button on the board and you should find an advertising BLE device called "Zephyr Peripheral Sample Long Name".

Monitor

You can use minicom to monitor the output in WSL:

sudo minicom -D /dev/ttyACM0

2. Defense capability

Adversary

We use the nRF52840 dongle as the adversary. Follow SweynTooth to install the firmware.

Victim

We integrate BlueSWAT with ZephyrOS and use the nRF52840 DK as the victim device.

BlueSWAT inspection rules are at ZephyrOS/zephyr/firewall/policy/ebpf_C_code. To compile them into eBPF programs, e.g., to compile conn_chan_map.ebpf.c, run ./compile.sh conn_chan_map. We have provided some compiled eBPF transition rules at ZephyrOS/zephyr/firewall/policy/ebpf_bytecode.

  1. Test the vulnerability without BlueSWAT.

After flash the ZephyrOS to the board, use SweynTooth Invalid Channel Map to launch the attack.

The Invalid Channel Map attack will trigger a kernel panic and crash the device.

  1. Load the defense rules into BlueSWAT and relaunch the attacks.

In ZephyrOS/zephyr/firewall/policy/include/fsm_policy_cache.h, add

enum fsm_policy_tag {
	PID_conn_chan_map,

	// FSM policy num
	PID_NUM,
};

In ZephyrOS/zephyr/firewall/policy/src/fsm_policy_cache.c, add

#include "ebpf_bytecode/conn_chan_map.h"

void load_all_policies()
{
	ADD_POLICY(conn_chan_map, CONN, CHANNEL_MAP);
}

Recompile the firmware and flash the nRF52840 DK board. Then, relaunch the attack with the dongle and the victim device should successfully mitigate the attack.

3. Memory consumption

Remove the above rules and compile the firmware, you should see the firmware size at the end of the compilation. Then, add ten rules

// ZephyrOS/zephyr/firewall/policy/include/fsm_policy_cache.h
enum fsm_policy_tag {
	PID_conn_chan_map,
	PID_conn_chan_hop,
	PID_ebpf_helper_test,
	PID_dc_nesn,
	PID_spi_acl_len,
	PID_spi_evt_len,
	PID_scan_rsp_len,
	PID_llcp_len_req,
	PID_llcp_conn_param_req,
	PID_lll_interval,

	// FSM policy num
	PID_NUM,
};

// ZephyrOS/zephyr/firewall/policy/src/fsm_policy_cache.c:
#include "ebpf_bytecode/conn_chan_map.h"
#include "ebpf_bytecode/conn_chan_hop.h"
#include "ebpf_bytecode/dc_nesn.h"
#include "ebpf_bytecode/spi_evt_len.h"
#include "ebpf_bytecode/spi_acl_len.h"
#include "ebpf_bytecode/scan_rsp_len.h"
#include "ebpf_bytecode/llcp_len_req.h"
#include "ebpf_bytecode/llcp_conn_param_req.h"
#include "ebpf_bytecode/lll_interval.h"
#include "ebpf_bytecode/smp_ident_check.h"

void load_all_policies()
{
	ADD_POLICY(conn_chan_map, CONN, CHANNEL_MAP);
	ADD_POLICY(conn_chan_hop, CONN, CHANNEL_HOP);
	ADD_POLICY(dc_nesn, DC, NESN);
	ADD_POLICY(spi_acl_len, SPI, HCI_ACL_LEN);
	ADD_POLICY(spi_evt_len, SPI, HCI_EVT_LEN);
	ADD_POLICY(scan_rsp_len, CONN, SCAN_RSP_LEN);
	ADD_POLICY(llcp_len_req, DC, LLCP_LEN_REQ);
	ADD_POLICY(llcp_conn_param_req, DC, LLCP_CONN_PARAM_REQ);
	ADD_POLICY(lll_interval, CONN, LLL_INTERVAL);
	ADD_POLICY(smp_ident_check, DC, SMP_KEYS);
}

Recompile the firmware and check the size of ten eBPF programs.

4. Runtime latency

Our artifact provides two BLE applications, which are Battery Level Service (BAS) and Heart Rate Service (HRS).

Mobile BLE apps can connect to our device and access these applications. The evaluation process is similar to the above:

  1. Load no rules and activate the HRS for 100 rounds. Record the time comsumption.
  2. Load one and ten rules and activate the HRS for 100 rounds. Record the time comsumption.
  3. Calculate the runtime latency introduced by BlueSWAT.

5. Power assess

We access the power and energy performance of BlueSWAT over a 120-second window, encompassing four phases: 20s of connection, 40s of BAS, another 20s of connection, and 40s of HRS.

We use ChargerLAB POWER-Z KT002 can record the Voltage, Current, and Power values during the testing window, and then compare the power increase introduced by BlueSWAT with baseline.

blueswat's People

Contributors

raycxggg avatar

Watchers

 avatar  avatar

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.