Giter Club home page Giter Club logo

vigiles-openwrt's Introduction

Timesys Vigiles

Timesys Vigiles For OpenWrt

This is a collection of tools for image manifest generation used for security monitoring and notification as part of the Timesys Vigiles product offering.

What is Vigiles?

Vigiles is a vulnerability management tool that provides build-time CVE Analysis of OpenWrt target images. It does this by collecting metadata about packages to be installed and uploading it to be compared against the Timesys CVE database.A high-level overview of the detected vulnerabilities is returned and a full detailed analysis can be viewed online.

Register (free) and download the API key to access the full feature set based on Vigiles Basic, Plus or Prime: https://linuxlink.timesys.com/docs/wiki/engineering/LinuxLink_Key_File

Using Vigiles CVE Check

To generate a vulnerability report follow the below steps:

  1. Clone vigiles-openwrt repository.

    git clone https://github.com/TimesysGit/vigiles-openwrt.git
  2. Download your LinuxLink Key File here and store it at the (recommended) path.

    mkdir $HOME/timesys
    cp $HOME/Downloads/linuxlink_key $HOME/timesys/linuxlink_key

    Note: If the key is stored elsewhere, the location can be specified via the Vigiles CVE Scanner (vigiles-openwrt.py) tool's command line argument (-K / --keyfile).

  3. Run Vigiles CVE Scanner (vigiles-openwrt.py) with paths of OpenWrt build directory and a Vigiles output directory path (where generated report and manifest would be kept).

    cd {vigiles-openwrt clone directory}
    ./vigiles-openwrt.py -b {path of openwrt directory} -o {path of Vigiles output directory}

    Example:

    ./vigiles-openwrt.py -b /home/user/projects/openwrt -o /home/user/vigiles/output

    Note: In case -o argument is not provided, the Vigiles CVE Scanner (vigiles-openwrt.py) would use {PWD}/vigiles-output as default Vigiles output directory .

  4. View the Vigiles CVE (Text) Report Locally

    The CVE report will be located in the {Vigiles output directory} provided while running the Vigiles CVE Scanner (vigiles-openwrt.py) tool, with a name based on the board name; e.g.:

    wc -l vigiles/output/ath79-report.txt
        240 vigiles/output/ath79-report.txtt
  5. View the Vigiles CVE Online Report

    The local CVE text report will contain a link to a comprehensive and graphical report; e.g.:

    -- Vigiles CVE Report --
            View detailed online report at:
              https://linuxlink.timesys.com/cves/reports/<Unique Report Identifier>
    

    The CVE Manifest

    The Vigiles CVE Scanner creates a manifest that it sends to the LinuxLink Server describing your build configuration. This manifest is located in the {Vigiles output directory} provided while running Vigiles CVE Scanner (vigiles-openwrt.py) (the same location as the text report it receives back).

    wc -l vigiles/output/ath79-manifest.json 
        854 vigiles/output/ath79-manifest.json

    In the event that something goes wrong, or if the results seem incorrect, this file may offer insight as to why. It's important to include this file with any support request.

Configuration

Reporting and Filtering

Linux Kernel and U-Boot .config filtering can be enabled/disabled using the options -k / --kernel-config and -u / --uboot-config.

If using a custom location for either the Kernel or U-Boot .config files, the paths can be specified using -k / --kernel-config and -u / --uboot-config.

The default for both paths is auto which results in automatically using the .config from the package's configured build directory. It is recommended that this value is used unless it is absolutely necessary to specify an alternative path.

In case you want to disable Linux Kernel and U-Boot .config filtering pass none as argument value.

Customizing / Amending the Vigiles Report

In some cases, it's desirable to modify the CVE report that Vigiles generates. vigiles-openwrt supports the ability to Include Additional Packages, Exclude Packages and Whitelist Known CVEs. In addition, the file names of the locally-generated Manifest and CVE Report may be customized.

All of these options are supported by a Vigiles CVE Scanner (vigiles-openwrt.py) argument where a user may specify a CSV (comma-separated-value) file that describe the packages or CVEs. Each is described below.

Manifest and Report Naming

By default, the file names of the Vigiles Manifest to be uploaded and the CVE Report that is generated are given names based on the value of kconfig CONFIG_TARGET_BOARD, which will produce files like this:

output
├── ath79-manifest.json
└── ath79-report.txt

To use a custom name for the local Vigiles Manifest that is uploaded and the CVE Report that is generated, the Vigiles CVE Scanner argument -N / --name can be used.

Example:

-N Custom-Name

Or

--name Custom-Name

If set to 'Custom-Name', the files produced will be:

output/vigiles
├── Custom-Name-manifest.json
└── Custom-Name-report.txt

Including Additional Packages

To include packages that are built outside the standard OpenWrt process (and therefore wouldn't be included in the Vigiles CVE Report), the Vigiles CVE Scanner argument -A / --additional-packages ("Additional Packages to Include in Report") may be set to the path of a CSV file.

Example:

-A /home/user/vigiles-additional-packages.csv

Or

--additional-packages /home/user/vigiles-additional-packages.csv

The CSV file consists of an optional header and the following fields:

  • Product - the CPE Name that packages use in CVEs
  • (optional) Version - the version of the package used.
  • (optional) License - the license of the package used

The following example shows the accepted syntax for expressing extra packages:

$ cat /home/user/vigiles-additional-packages.csv
product,version,license
avahi,0.6
bash,4.0
bash,4.1,GPL 3.0
busybox,
udev,,"GPLv2.0+, LGPL-2.1+"

Excluding Packages

In some cases, a more condensed CVE Report may be desired, so a list of specific packages to omit may be specified (for example: packages that only install data files).

To exclude packages from the CVE Report, the Vigiles CVE Scanner argument -E / --exclude-packages may be set to the path of CSV file.

Example:

-E /home/user/vigiles-exclude-packages.csv

Or

--exclude-packages /home/user/vigiles-exclude-packages.csv

The CSV file expects one package name per line. Any additional CSV fields are ignored.

For example:

$ cat /home/user/vigiles-exclude-packages.csv
linux-libc-headers
opkg-utils
packagegroup-core-boot

Whitelisting CVEs

Some packages may have CVEs associated with them that are known to not affect a particular machine or configuration.

A user may set the Vigiles CVE Scanner argument -W / --whitelist-cves to the path of a CSV file containing a list of CVEs to omit from the Vigiles Report.

Example:

-W /home/user/vigiles-cve-whitelist.csv

Or

--whitelist-cves /home/user/vigiles-cve-whitelist.csv

The CSV expects one CVE ID per line. Any additional fields will be ignored.

For example:

$ cat /home/user/vigiles-cve-whitelist.csv
CVE-2021-37155
CVE-2018-12886

Uploading the Manifest (Only)

In some cases, it may be desired to upload the Vigiles Manifest for a build without generating a CVE Report.

This behavior can be enabled with the Vigiles CVE Scanner argument -U / --upload-only.

Instead of a text report and a link to the online report, a link to the Vigiles Dashboard Product Workspace (as specified with VIGILES_DASHBOARD_CONFIG) will be displayed, from where it can be then be scanned by the Vigiles Service.

LinuxLink Credentials

To specify an alternative location for the Timesys LinuxLink Key File, (default: $(HOME)/timesys/linuxlink_key) it can be set with the Vigiles CVE Scanner argument -K / --keyfile.

Example:

-K /home/user/mylinuxlink_key

Or

--keyfile /home/user/mylinuxlink_key

Whether the default is used, or if Vigiles CVE Scanner argument option is set, it will be overridden by the environment variable VIGILES_KEY_FILE.

Vigiles Dashboard Configuration

A custom LinuxLink Dashboard configuration can be set by specifying the path in the Vigiles CVE Scanner argument -C / --dashboard-config. If not provided, a default path will be used ($(HOME)/timesys/dashboard_config)

Example:

-C /home/user/mydashboard_config

Or

--dashboard-config /home/user/mydashboard_config

Whether the default is used, or if Vigiles CVE Scanner argument option is set, it will be overridden by the environment variable VIGILES_DASHBOARD_CONFIG.

By default, your manifest will be uploaded to your "Private Workspace" Product on the Vigiles Dashboard. This can be changed by downloading the "Dashboard Config" for an alternative Product and/or Folder.

Dashboard Config files will be downloaded by default to e.g. "${HOME}/Downloads/dashboard_config". Once moving and/or renaming it as necessary, you can control the behavior of Vigiles for openwrt by passing the dashboard config argument as explained above.

New Products can be defined by clicking on the "New Product" product link and specifying a name. To download the Dashboard Config for the top-level folder of that Product, click on the "Product Settings" link and then the "Download Dashboard Config" button.

Once a new product is created, sub-folders may be created by clicking on the "Create Folder" and specifying a name. The Dashboard Config for that Folder (in that Product) may be downloaded by first clicking on/opening the Folder, then clicking the "Folder Settings" link and finally the "Download Dashboard Config" button.

Dynamic subfolder creation

If a Dashboard Config is used, a subfolder name can be specified for dynamic folder creation by the Vigiles CVE Scanner argument -F / --subfolder. Manifests will be uploaded to a subfolder with this name within the location specified in the Dashbord Config. If one does not exist, it will be created. This option will be overridden by the environment variable VIGILES_SUBFOLDER_NAME

Example:

-F mysubfolder

Or

--subfolder mysubfolder

Advanced Options

For development purposes, some "Expert" options are available. These allow for debugging of the metadata that is collected. These features are not supported and no documentation is provided for them.

Write Intermediate JSON Files of Collected Metadata: -I, --write-intermediate

Enable Debug messages: -D, --enable-debug

Generate a SBOM without performing a vulnerability scan: -M, --metadata-only

Other Notes

Package Version Information in Generated SBOM

Openwrt includes packages/config scripts lacking version information (Ex. base-files, urandom-seeds, etc.). In the generated SBOM for such packages version is set to the Openwrt distro version.

Maintenance

The Vigiles CVE Scanner and OpenWrt support are maintained by The Timesys Security team.

For Updates, Support and More Information, please see:

Vigiles Website

vigiles-openwrt's People

Contributors

harish-bansal avatar iancampbell avatar indresh-timesys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vigiles-openwrt's Issues

Kernel Build directory not found

Hello, I have tried to run a scan on an openwrt generic x86 build.
The scan runs fine and find userspace vulnerabilities until the kernel config is retrieved and I get the Warning message :
"Vigiles WARNING: Kernel Config: Kernel Build directory not found."

Using the -k option with specific path to the kernel configuration in the debug messages i can see that the kernel configuration is taken into account, but if I read the documentation correctly, this option only allows you to filter the CVEs ?

How can I get Vigiles to find my Kernel build directory? Or what is the default path to use in order to retrieve this configuration?

Thank you for your answer

--whitelist-cves does not appear to work

--whitelist-cves does not appear to work.

Using the --whitelist-cves vigiles-cve-whitelist.csv option, where vigiles-cve-whitelist.csv looks as follows:

CVE-2020-7982
CVE-2020-24342
CVE-2020-15888
CVE-2020-15945
CVE-2020-15889
CVE-2021-0326
CVE-2020-36254
CVE-2021-43523
CVE-2021-3711
CVE-2021-20305
CVE-2021-3580

does not result in whitelisted CVEs (they remain marked Unfixed) in the vigiles CVE Dashboard.

Python3 Version is not specified; `vigiles-openwrt.py` throws versioning related errors.

The python3 version is not specified in any meaningful way. All the libraries used are from the python standard library, but are often used with deprecated function arguments.

For example, the encoding option (file lib/libapi.py line 50) has been deprecated since python 3.1 and was removed in python 3.9. Executing this code throws an exception and results in the error:

Error: Unable to parse key file: /home/$user/timesys/linuxlink_key

I can verify the file /home/$user/timesys/linuxlink_key exists, is accessible, and is legal JSON.

Removing this argument or using python 3.8.10 gets us past this error. We then receive a communication error:

	Vigiles Communication Error:	Invalid credentials were sent to the LinuxLink Server.
	
	Current Time:	2022-01-30T20:10:02.073147
	Message:	HTTP Error 403: FORBIDDEN
	Parameter(s):	https://linuxlink.timesys.com/api/v1/vigiles/manifests

I have not dug any deeper into the code determine why API authentication / communications are failing.

combinatorial explosion using os.walk(..., followlinks=True)

Our build root includes acl which has an two symlinks in its include directory similar to this:

[dustin@rigel include]$ ls -l
total 0
lrwxrwxrwx 1 dustin dustin 2 Oct 14 12:40 acl -> ..
lrwxrwxrwx 1 dustin dustin 2 Oct 14 12:40 sys -> ..
[dustin@rigel include]$ 

This causes a vigiles-openwrt.py to spin possible combinations directory paths permutations of sys and acl until it hits ELOOP.

vigiles-openwrt does not detect all packages configured in the openwrt build config.

vigiles-openwrt does not detect all packages configured in the openwrt build config.

Some configured packages from base openwrt buildroot are excluded that should not be - It seems to only select a small subset of packages from the openwrt buildroot config.

Also all packages configured in the config that exist in the openwrt feeds are excluded.

These packages are all included through the standard OpenWrt build process thus we should not have to specify them using the -A / --additional-packages mechanism.

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.