Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8a77214

Browse files
committedMar 27, 2025
Add CL_TYPE_AI_MODEL and associated file type magic signatures
This is just preliminary support for identifying an assortment of different AI model files. So far, this detects the following types: - GGML GGUF (.gguf) - ONNX AI (.onnx) - TensorFlow Lite (.tflite) Additional types to consider: - SafeTensors (.safetensors) - TensorFlow (.pb, .ckpt, .tfrecords) - Keras (.keras) - pickle (.pkl) - numpy (.npy, .npz) - coreml (.coreml) - PyTorch (.pt, .pth, .bin, .mar, .pte, .pt2, .ptl) Outside of being able to differentiate by file type, the scanner will treat CL_TYPE_AI_MODEL the same as CL_TYPE_BINARY_DATA. We're not adding parsers to further process these files, for now.
1 parent 640413d commit 8a77214

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed
 

‎libclamav/filetypes.c

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static const struct ftmap_s {
142142
{ "CL_TYPE_ONENOTE", CL_TYPE_ONENOTE },
143143
{ "CL_TYPE_PYTHON_COMPILED", CL_TYPE_PYTHON_COMPILED },
144144
{ "CL_TYPE_LHA_LZH", CL_TYPE_LHA_LZH },
145+
{ "CL_TYPE_AI_MODEL", CL_TYPE_AI_MODEL },
145146
{ NULL, CL_TYPE_IGNORED }
146147
};
147148
// clang-format on

‎libclamav/filetypes.h

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ typedef enum cli_file {
9595
CL_TYPE_ONENOTE,
9696
CL_TYPE_PYTHON_COMPILED,
9797
CL_TYPE_LHA_LZH,
98+
CL_TYPE_AI_MODEL,
9899

99100
/* Section for partition types */
100101
CL_TYPE_PART_ANY, /* unknown partition type */

‎libclamav/filetypes_int.h

+22
Original file line numberDiff line numberDiff line change
@@ -302,5 +302,27 @@ static const char *ftypes_int[] = {
302302
"1:2:2d6c7a(73|34|35)2d:LHA archive using .LZS extension:CL_TYPE_ANY:CL_TYPE_LHA_LZH:210",
303303
"1:2:2d706d302d:LHA archive using PMarc (.PMA) extension:CL_TYPE_ANY:CL_TYPE_LHA_LZH:210",
304304
"0:0:414c5a01:ALZ:CL_TYPE_ANY:CL_TYPE_ALZ:210",
305+
// GGML GGUF models
306+
"0:0:4747554601000000:GGUF AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
307+
"0:0:4747554602000000:GGUF AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
308+
"0:0:4747554603000000:GGUF AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
309+
// ONNX AI model detection, looking for: onnx_tool or onnx-tool
310+
"1:0:08??12??6f6e6e78(2d|5f)746f6f6c:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
311+
// ONNX AI model detection, looking for: tf2onnx
312+
"1:0:08??12??7466326f6e6e78:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
313+
// ONNX AI model detection, looking for: pytorch
314+
"1:0:08??12??7079746f726368:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
315+
// ONNX AI model detection, looking for: caffe:
316+
"1:0:08??12??63616666653a:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
317+
// ONNX AI model detection, looking for: OnnxMLTools:
318+
"1:0:08??12??4f6e6e784d4c546f6f6c73:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
319+
// ONNX AI model detection, looking for: CNTK
320+
"1:0:08??12??434e544b:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
321+
// ONNX AI model detection, looking for: onnx-caffe2:
322+
"1:0:08??12??6f6e6e782d636166666532:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
323+
// ONNX AI model detection, looking for: onnx-caffe2:
324+
"1:0:08??12??6f6e6e782d636166666532:ONNX AI Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
325+
// tflite model detection
326+
"0:4:54464c33:TensorFlow Lite Model File:CL_TYPE_ANY:CL_TYPE_AI_MODEL:220",
305327
NULL};
306328
#endif

‎libclamav/scanners.c

+1
Original file line numberDiff line numberDiff line change
@@ -5448,6 +5448,7 @@ cl_error_t cli_magic_scan(cli_ctx *ctx, cli_file_t type)
54485448
perf_nested_stop(ctx, PERFT_MACHO, PERFT_SCAN);
54495449
break;
54505450

5451+
case CL_TYPE_AI_MODEL:
54515452
case CL_TYPE_PYTHON_COMPILED:
54525453
case CL_TYPE_BINARY_DATA:
54535454
ret = cli_scan_fmap(ctx, CL_TYPE_OTHER, false, NULL, AC_SCAN_VIR, NULL, NULL);

0 commit comments

Comments
 (0)
Failed to load comments.