Skip to content

C/C++ Library Scan (Identification)#

This method identifies C/C++ libraries whose source code you have incorporated directly into a project without using a package manager, and manages their vulnerabilities.

Item Description
Target Source code of C/C++ libraries incorporated into a project (such as zlib, libxml2, and expat)
Prerequisites An environment in which to run the dedicated command futurevuls-cpp-fingerprint (see "Supported Environments"), a FutureVuls API token, and Automatic CPE Assignment enabled in the group settings
Registration destination The Application tab of a registered server. You send the data through the FutureVuls API. If you have no server to use as the registration destination, create a pseudo server and use it as the registration destination
Update timing You run the command and send the data through the API. You can automate this by integrating it into CI/CD

Overview#

Libraries installed with the OS package manager are recorded in the package ledger and become targets of configuration and vulnerability management. Libraries placed as source code are not recorded in any ledger, so neither configuration nor vulnerability management is possible

The feature generates hashes from copied C/C++ library source code and automatically identifies and manages each library's repository and version in FutureVuls.

Run futurevuls-cpp-fingerprint in your environment to generate hashes, then send only the directory name and hashes to FutureVuls through the API. FutureVuls matches the hashes with OSV, identifies the repository and version, and registers them for configuration management

Background: Why C/C++ library configuration management is complex

For the background on why configuration management of C/C++ libraries is complex, see the FutureVuls Blog article Why is configuration management of C/C++ libraries difficult? (in Japanese).

Supported Environments#

The binaries are statically linked and require no additional dependencies.

OS / architecture
linux/amd64
linux/arm64
windows/amd64

Identification Targets#

Target Files#

The feature targets files with the following extensions in the specified directories.

  • .c, .cc, .cpp, .h, .hh, .hpp (lowercase extensions only; .C and .H are not targeted)

The feature also targets subdirectories. However, it does not target directories whose names start with . (such as .git) or symbolic links.

Files with CRLF line endings cannot be identified

The feature hashes file contents as is, without converting line endings. The hashes used for matching are generated from sources with LF line endings, so files converted to CRLF do not match. If the sources include files with CRLF line endings, such as sources obtained on Windows with Git's core.autocrlf enabled, futurevuls-cpp-fingerprint displays a warning. Specify sources whose line endings remain LF.

Supported Libraries#

FutureVuls currently supports C/C++ open-source projects managed in Google/OSS-Fuzz (project list). FutureVuls identifies repositories and versions by querying OSV (Open Source Vulnerabilities), an external service, with the hashes it receives.

Data Sent to FutureVuls#

  • Data sent to FutureVuls: The final name of each specified directory (used as the component name) and the MD5 hash of each file
  • Data not sent: Source code, file names, and absolute or relative paths

FutureVuls queries OSV with only the hashes.

Usage Examples#

Use the following process to identify copied library source code.

  1. Generate library identification data: Run futurevuls-cpp-fingerprint and generate futurevuls-cpp-library.json, which records source-code hashes. Run the command by specifying the directory of each library (one directory per library, as in third_party/zlib third_party/libxml2 in the examples below).
  2. Send data to FutureVuls: Send the generated JSON file to the FutureVuls API from a local environment or CI/CD pipeline.
  3. Automatic identification: On receiving the data, FutureVuls checks the hashes, identifies each library's repository and version, and registers the libraries as software of the registration destination server.
  4. Review results: Review identification results in the console or through the FutureVuls API.
  5. Vulnerability detection: When the registration destination server is scanned, CPEs are automatically assigned to the identified libraries and vulnerabilities are detected (when Automatic CPE Assignment is enabled in the group settings; see "Prerequisites"). Identification runs asynchronously after the data is sent, so to detect them immediately, run a manual scan from the server details after the identification results appear in step 4. When the next scan runs depends on how the registration destination server was registered and on your plan (see "Target Servers of Periodic Automatic Scans").

FutureVuls handles futurevuls-cpp-library.json as a type of Lockfile. For this reason, you use the Lockfile APIs to send it, and the results are displayed in the Application tab of the server details.

For the first upload, use the Add Lockfile API (POST /v1/lockfile). To update a registered futurevuls-cpp-library.json, use the Update Lockfile API (PUT /v1/lockfile/{lockfileID}). The following examples show the first upload (POST).

Prerequisites#

Enable Automatic CPE Assignment in Group Settings. FutureVuls assigns CPEs to identified libraries through Automatic CPE Assignment during scans. When it is disabled, CPEs are not assigned automatically. For libraries with no assigned CPE, vulnerabilities cannot be detected. For details, see Automatic CPE Assignment.

Register the destination server (the registration destination) in FutureVuls in advance. If you have no server to use as the registration destination, create a pseudo server from Add Server → Add Pseudo Server on the Server / Product tab.

The values used in the procedure are as follows.

Value Description How to Obtain Use Case
SERVER_ID The ID of the registration destination server How to get serverID The first upload (POST /v1/lockfile)
FVULS_TOKEN A group token whose API permission includes Update FutureVuls API Token Management All uploads
lockfileID The ID of the registered futurevuls-cpp-library.json How to get lockfileID Updating registered data (PUT /v1/lockfile/{lockfileID})
FVULS_SERVER_UUID The UUID of the registration destination server How to get UUID Uploads from GitHub Actions (CI/CD integration)

The following examples stop if downloading the installer script or generating identification data fails, so that an old JSON file is not uploaded.

Linux#

set -euo pipefail

# Use the installer script to hash the sources in the specified directories and generate futurevuls-cpp-library.json
curl -fsSL -o futurevuls-cpp-fingerprint.sh https://installer.vuls.biz/futurevuls-cpp-fingerprint.sh
bash futurevuls-cpp-fingerprint.sh <library-directories> # Specify one or more directories of libraries to identify
# Example: bash futurevuls-cpp-fingerprint.sh third_party/*/
# Example: bash futurevuls-cpp-fingerprint.sh third_party/zlib third_party/libxml2

# Encode the generated file as Base64 to build the request body, then POST it
# (Write the body to a file and send it, because a large file does not fit in the command arguments)
SERVER_ID=<server-id> # Specify SERVER_ID from the prerequisites
FVULS_TOKEN=<api-token> # Specify FVULS_TOKEN from the prerequisites

{
  printf '{"serverID":%s,"path":"futurevuls-cpp-library.json","fileContent":"' "${SERVER_ID}"
  base64 -w 0 futurevuls-cpp-library.json
  printf '"}'
} > futurevuls-cpp-request.json

curl -fsS -X POST 'https://rest.vuls.biz/v1/lockfile' \
  -H 'Content-Type: application/json' \
  -H "Authorization: ${FVULS_TOKEN}" \
  --data-binary @futurevuls-cpp-request.json

Windows#

$ErrorActionPreference = "Stop"

# Save the installer script
curl.exe -fsS -o futurevuls-cpp-fingerprint.bat https://installer.vuls.biz/futurevuls-cpp-fingerprint.bat
if ($LASTEXITCODE -ne 0) { throw "futurevuls-cpp-fingerprint download failed: $LASTEXITCODE" }

# Generate futurevuls-cpp-library.json
cmd /c ".\futurevuls-cpp-fingerprint.bat <library-directories>" # Specify one or more directories of libraries to identify
# Example: cmd /c ".\futurevuls-cpp-fingerprint.bat third_party\zlib third_party\libxml2"
# Example: specify each directory under third_party (paths must not contain spaces)
#   $dirs = (Get-ChildItem -Directory third_party).FullName
#   cmd /c ".\futurevuls-cpp-fingerprint.bat $dirs"
if ($LASTEXITCODE -ne 0) { throw "futurevuls-cpp-fingerprint failed: $LASTEXITCODE" }

# Encode the generated file as Base64 and send it through POST
$fileContent = [Convert]::ToBase64String([IO.File]::ReadAllBytes((Resolve-Path .\futurevuls-cpp-library.json).ProviderPath))
$serverID = <server-id> # Specify SERVER_ID from the prerequisites
$fvulsToken = "<api-token>" # Specify FVULS_TOKEN from the prerequisites
$body = @{ serverID = $serverID; path = "futurevuls-cpp-library.json"; fileContent = $fileContent } | ConvertTo-Json -Compress
Invoke-RestMethod -Method Post -Uri "https://rest.vuls.biz/v1/lockfile" -Headers @{ Authorization = $fvulsToken } -ContentType "application/json" -Body $body

Proxy environments

Downloading the installer script and the binary requires proxy settings. On Linux, set the https_proxy environment variable by referring to Proxy Configuration. On Windows, set the proxy server URL in the VULS_PROXY environment variable and specify --proxy for curl.exe.

CI/CD Integration#

For how to integrate scanning of container images and of dependency libraries managed with lockfiles into CI/CD, see "CI/CD Integration".

In GitHub Actions, generate library identification data and upload it with futurevuls/fvuls-lockfile-uploader. Set path to futurevuls-cpp-library.json.

Because the example below specifies repoName, the registered path becomes <owner>/<repository name>/futurevuls-cpp-library.json (see the table in "CI/CD Integration"). This path differs from the futurevuls-cpp-library.json you registered manually in the steps above, so if you send it to the same server, it is registered as a separate lockfile. To update the manually registered data from CI/CD, delete the repoName line. After the run, you can confirm in "Application" in the server details that the existing futurevuls-cpp-library.json has been updated.

name: Upload C/C++ library identification data

on:
    push:
        branches:
            - <branch-name> # Specify the branch name to release from
        paths:
            - "<library-directory>/**" # Specify the directory that contains libraries to identify

permissions:
    contents: read

jobs:
    upload-cpp-library:
        runs-on: ubuntu-26.04
        steps:
            - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
            - name: Generate C/C++ library identification data
              shell: bash
              run: |
                  set -euo pipefail
                  curl -fsSL -o futurevuls-cpp-fingerprint.sh https://installer.vuls.biz/futurevuls-cpp-fingerprint.sh
                  bash futurevuls-cpp-fingerprint.sh <library-directories> # Specify one or more directories of libraries to identify
                  # Example: bash futurevuls-cpp-fingerprint.sh third_party/*/
                  # Example: bash futurevuls-cpp-fingerprint.sh third_party/zlib third_party/libxml2
            - name: Upload C/C++ library identification data
              uses: futurevuls/fvuls-lockfile-uploader@9245e71ad5a5833acf0196650027fc4a6be78921 # v2
              env:
                  # Set GitHub Repository Secrets
                  FVULS_SERVER_UUID: ${{ secrets.FVULS_SERVER_UUID }}
                  FVULS_TOKEN: ${{ secrets.FVULS_TOKEN }}
              with:
                  repoName: ${{ github.repository }}
                  path: "./futurevuls-cpp-library.json"

Reviewing Results#

Review identification results on the Applications detail page and through FutureVuls API GET /v1/lockfile/{lockfileID}. When FutureVuls cannot identify a component, review the error message on the same page or through the API.

If a library is not registered or vulnerabilities are not detected, check the cause in the following table.

Situation Scope of impact Action
futurevuls-cpp-library.json exceeds the limits (50 components, and 5,000 hashes per component) The entire file is rejected Regenerate the JSON within the limits and send it again (see "File Limits")
No repository matches, multiple candidate repositories remain, or the version cannot be identified Only the affected component is not registered Review the error message in the identification results
Any query to OSV fails Successfully identified components are not registered either If the cause is a network error or similar, upload the data again to retry
The library is identified, but no official CPE exists for it No CPE is assigned, and CPE-based vulnerability detection is not performed See "Libraries Without a CPE"
The library is identified, but Automatic CPE Assignment is disabled in Group Settings No CPE is assigned automatically, and vulnerabilities cannot be detected unless a CPE is already assigned Enable Automatic CPE Assignment (see "Prerequisites")

The application detail page shows the components that could not be identified and why under source identification results, and the identified libraries and versions under Software

Limitations#

File Limits#

Each futurevuls-cpp-library.json can contain up to 50 components (the library directories you specified). Each component can contain up to 5,000 hashes. FutureVuls rejects the entire file when either limit is exceeded. futurevuls-cpp-fingerprint warns about an exceeded limit but still writes JSON.

Libraries Without a CPE#

Even when FutureVuls correctly identifies a repository and version, it does not register a CPE or link CPE-based vulnerability information when NVD or another source has not assigned an official CPE to the software.