trailofbits
Written by the Trail of Bits security experts. See https://github.com/trailofbits/semgrep-rules for more.
Run Locally
Rules (46)

Possible race condition due to memory aliasing of variable `$X`

Potential goroutine leak due to unbuffered channel send inside loop or unbuffered channel receive in select block

Iteration over a possibly empty map `$C`. This is likely a bug or redundant code.

Potential `$FOO` nil dereference when `$BAR` is called

Logic executed as a result of ticker `$TICKER` may execute more times than desired. When both `$TICKER` and `$DONECHAN` are written to at the same time, the scheduler randomly picks a case to execute. As a result, the `$TICKER.C` may excute one more time than expected.

Should `$X` be modified when an error could be returned?

Appending `$SLICE` from multiple goroutines is not concurrency safe

Writing `$MAP` from multiple goroutines is not concurrency safe

The `func ($O *$CODEC) ReadRequestBody($ARG $TYPE) error` function does not handle `nil` argument, as the `ServerCodec` interface requires. An incorrect implementation could lead to denial of service

Using `time.Sleep` for synchronizations is generally considered bad practice.

Downcasting or changing sign of an integer with `$CAST_METHOD` method

A `sync.Mutex` is copied in function `$FUNC` given that `$T` is value receiver. As a result, the struct `$T` may not be locked as intended

Unchecked type assertion.

Calling `$WG.Add` inside of an anonymous goroutine may result in `$WG.Wait` waiting for more or less calls to `$WG.Done()` than expected

Calling `$WG.Wait()` inside a loop blocks the call to `$WG.Done()`

Possible path traversal through `tarfile.open($PATH).extractall()` if the source tar is controlled by an attacker

Variable `$X` is likely modified and later used on error. In some cases this could result in panics due to a nil dereference

Iteration over a possibly empty map `$C`. This is likely a bug or redundant code

Missing `RUnlock` on an `RWMutex` lock before returning from a function

Missing mutex unlock before returning from a function. This could result in panics resulting from double lock operations

The function is vulnerable to DLL hijacking attacks. Use `windows.NewLazySystemDLL()` function to limit DLL search to the Windows directory

If possible, it is better to rely on automatic pinning in PyTorch to avoid undefined behavior and for efficiency

Found usage of the `$FLAVOR` library, which is vulnerable to attacks such as XML external entity (XXE) attacks

NumPy distutils is deprecated, and will be removed in the future

Compiling arbitrary code can result in code execution. Ensure the source code is from a trusted location

Using the NumPy RNG inside of a PyTorch dataset can lead to a number of issues with loading data, including identical augmentations. Instead, use the random number generators built into Python and PyTorch

Usage of NumPy library inside PyTorch `$MODULE` module was found. Avoid mixing these libraries for efficiency and proper ONNX loading

Using the NumPy RNG inside of a Torch dataset can lead to a number of issues with loading data, including identical augmentations. Instead, use the random number generators built into Python and PyTorch

Loading custom operator libraries can result in arbitrary code execution

Loading custom operator libraries can result in arbitrary code execution

Functions reliant on pickle can result in arbitrary code execution. Consider using fickling or switching to a safer serialization method

Functions reliant on pickle can result in arbitrary code execution. Consider using fickling or switching to a safer serialization method

Functions reliant on pickle can result in arbitrary code execution

Functions reliant on pickle can result in arbitrary code execution. Consider loading from `state_dict`, using fickling, or switching to a safer serialization method like ONNX

Functions reliant on pickle can result in arbitrary code execution

Loading custom operator libraries can result in arbitrary code execution

Avoid importing torch.package - it can result in arbitrary code execution via pickle

Avoid using `torch.Tensor()` to directly create a tensor for efficiency and proper parsing

Scikit `joblib` uses pickle under the hood. Functions reliant on pickle can result in arbitrary code execution. Consider using `skops` instead.

Loading custom operator libraries can result in arbitrary code execution

Loading custom operator libraries can result in arbitrary code execution

Avoid importing torch.package - it can result in arbitrary code execution via pickle

Avoid using `torch.Tensor()` to directly create a tensor for efficiency and proper parsing

Not waiting for requests is a source of undefined behavior

Not waiting for requests is a source of undefined behavior

`expect` or `unwrap` called in function returning a `Result`