Compare commits
19 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4befabc967 | ||
| 5fa0ca0444 | |||
|
|
5220fca398 | ||
|
|
c08bdc9480 | ||
|
|
1d538cd169 | ||
| fa5e0287e5 | |||
| b540edbe1e | |||
| 64ecd5ada1 | |||
| 6df0c32f25 | |||
| 743263dc43 | |||
| b3aa0b6ddd | |||
|
|
bd11d89dde | ||
| 720ff42f34 | |||
| 04969ee6f8 | |||
| 0573622056 | |||
| 29d1c32e9d | |||
| 381616f682 | |||
| 290989064d | |||
|
|
ebd3333a14 |
47 changed files with 1108 additions and 7 deletions
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
build/
|
||||
data/
|
||||
bin/
|
||||
|
||||
AFLplusplus/
|
||||
aflfuzz/configs/
|
||||
aflfuzz/fuzz_out/
|
||||
|
||||
test_data.db
|
||||
101
README.md
101
README.md
|
|
@ -1,5 +1,7 @@
|
|||
# Linux Auth — Приложение аутентификации на Linux
|
||||
|
||||
**[Аналитический отчёт](analysis_report.md)**
|
||||
|
||||
Linux Auth — консольное приложение для аутентификации пользователей на Linux (Debian 12) с использованием локальной SQLite базы данных.
|
||||
Поддерживает:
|
||||
|
||||
|
|
@ -143,4 +145,101 @@ bash scripts/run.sh
|
|||
Добавить нового пользователя:
|
||||
```
|
||||
./build/release/add_user -username test -password 1234
|
||||
```
|
||||
```
|
||||
|
||||
# Анализ безопасности
|
||||
|
||||
## SAST (статический анализ)
|
||||
|
||||
### Настройка окружения
|
||||
|
||||
```bash
|
||||
bash scripts/config_sast.sh
|
||||
```
|
||||
|
||||
### Запуск анализа
|
||||
|
||||
Человекочитаемые результаты (txt формат файлов):
|
||||
|
||||
```bash
|
||||
bash scripts/run_sast.sh
|
||||
```
|
||||
|
||||
Вывод в формате sarif:
|
||||
|
||||
```bash
|
||||
bash scripts run_sast_sarif.sh
|
||||
```
|
||||
|
||||
Результаты анализа в sast_results (3 утилиты для SAST).
|
||||
|
||||
## Фаззинг
|
||||
|
||||
Сначала соберите приложение и инициализируйте тестовую базу (init_users).
|
||||
|
||||
Далее (для учебных целей фаззинг ограничен по времени - 5 минут):
|
||||
|
||||
1. Запуск нативного фаззера (проверка функции аутентификации, ограничение в 1 поток для нормальной работы БД SQLite)
|
||||
|
||||
1.1. cd myfuzz
|
||||
|
||||
1.2. ./run_fuzz.sh
|
||||
|
||||
1.3. ./view_fuzz_coverage.sh
|
||||
|
||||
2. Запуск AFL++ в режиме blackbox (фаззинг готового бинарника)
|
||||
|
||||
2.1. cd aflfuzz
|
||||
|
||||
2.2. ./install.sh
|
||||
|
||||
2.3. ./run_fuzz.sh
|
||||
|
||||
### Попытка скрестить gccgo и afl провалилась, оставлю для истории
|
||||
|
||||
3. Запуск AFL++ при компиляции через gccgo (установите AFL++ как в пункте 2.2. если ещё не сделали этого)
|
||||
|
||||
3.1. cd aflfuzz
|
||||
|
||||
3.2. ./install_gccgo_for_afl.sh
|
||||
|
||||
3.3. ./build_for_afl.sh
|
||||
|
||||
3.4. ./run_afl.sh
|
||||
|
||||
### Черновики для go-fuzz
|
||||
|
||||
На данный момент установка по официальной инструкции https://github.com/dvyukov/go-fuzz/blob/master/README.md не работает по причине golang.org/x/tools@v0.44.0 requires go >= 1.25.0 (running go 1.24.4)
|
||||
|
||||
4. Запуск go-fuzz
|
||||
|
||||
4.1. cd myfuzz
|
||||
|
||||
4.2. ./install_go-fuzz.sh (тут возникают проблемы, поэтому следующие шаги проверить не удалось + оказалось, что первая версия конфликтует с нативным фаззингом из пункта 1)
|
||||
|
||||
4.3. ./build_for_go-fuzz.sh
|
||||
|
||||
4.4. ./run_go-fuzz.sh
|
||||
|
||||
### Последняя попытка (тоже неудачная)
|
||||
|
||||
Утилита обещает поддержку 4 фаззеров, оказалось это просто обёртка для генерации тестов в 4 форматах и запуска фаззеров.
|
||||
Из заявленных фаззеров удалось запустить только нативный (но я это и так сделал в пункте 1), а также сгенерировать тест для go-fuzz (но запустить не удалось, см. пункт 4 выше), для libfuzzer и afl даже тесты не сгенерировались (как я понял, тоже надо самому установить все нужные бинарники).
|
||||
|
||||
5. Запуск golang-fuzz
|
||||
|
||||
5.1. cd golang-fuzz
|
||||
|
||||
5.2. ./install_golang-fuzz.sh
|
||||
|
||||
5.3. ./run_golang-fuzz.sh
|
||||
|
||||
## Анализ зависимостей на известные уязвимости
|
||||
|
||||
Используется версия govulncheck 1.1.4, т.к. следующие (1.2.0, 1.3.0) требуют Go версии 1.25.
|
||||
|
||||
1. cd govulncheck
|
||||
|
||||
2. ./install.sh
|
||||
|
||||
3. ./run.sh
|
||||
|
|
|
|||
19
aflfuzz/build_for_afl.sh
Executable file
19
aflfuzz/build_for_afl.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
export AFL_CC=gccgo
|
||||
export GCCGO=afl-gcc-fast
|
||||
|
||||
#unset GOROOT
|
||||
go build -v -x -compiler=gccgo -o authapp_for_afl ../cmd/authapp/main.go
|
||||
|
||||
exit 0
|
||||
|
||||
go build -a -toolexec="afl-gcc-fast" -o authapp_for_afl ../cmd/authapp/main.go
|
||||
|
||||
exit 0
|
||||
|
||||
export AFL_CC=gccgo
|
||||
|
||||
afl-gcc-fast -o authapp_for_afl ../cmd/authapp/main.go
|
||||
|
||||
exit 0
|
||||
2
aflfuzz/fuzz_in/blank_test.txt
Normal file
2
aflfuzz/fuzz_in/blank_test.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
|
||||
2
aflfuzz/fuzz_in/right_admin.txt
Normal file
2
aflfuzz/fuzz_in/right_admin.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
admin
|
||||
admin123
|
||||
2
aflfuzz/fuzz_in/right_user.txt
Normal file
2
aflfuzz/fuzz_in/right_user.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
user1
|
||||
password1
|
||||
2
aflfuzz/fuzz_in/wrong_admin.txt
Normal file
2
aflfuzz/fuzz_in/wrong_admin.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
admin
|
||||
admin
|
||||
2
aflfuzz/fuzz_in/wrong_user.txt
Normal file
2
aflfuzz/fuzz_in/wrong_user.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
user
|
||||
password
|
||||
19
aflfuzz/install.sh
Executable file
19
aflfuzz/install.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# apt install afl++ не поддерживает qemu режим, соберём из исходников
|
||||
# https://github.com/AFLplusplus/AFLplusplus/blob/stable/docs/INSTALL.md
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential python3-dev automake cmake git flex bison libglib2.0-dev libpixman-1-dev python3-setuptools cargo libgtk-3-dev
|
||||
# try to install llvm-18 and install the distro default if that fails
|
||||
sudo apt-get install -y lld-18 llvm-18 llvm-18-dev clang-18 || sudo apt-get install -y lld llvm llvm-dev clang
|
||||
sudo apt-get install -y gcc-$(gcc --version|head -n1|sed 's/\..*//'|sed 's/.* //')-plugin-dev libstdc++-$(gcc --version|head -n1|sed 's/\..*//'|sed 's/.* //')-dev
|
||||
sudo apt-get install -y meson ninja-build # for QEMU mode
|
||||
sudo apt-get install -y cpio libcapstone-dev # for Nyx mode
|
||||
sudo apt-get install -y wget curl # for Frida mode
|
||||
sudo apt-get install -y python3-pip # for Unicorn mode
|
||||
git clone https://github.com/AFLplusplus/AFLplusplus
|
||||
cd AFLplusplus
|
||||
git submodule update --init
|
||||
make distrib
|
||||
sudo make install
|
||||
4
aflfuzz/install_gccgo_for_afl.sh
Executable file
4
aflfuzz/install_gccgo_for_afl.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gccgo
|
||||
10
aflfuzz/run_afl.sh
Executable file
10
aflfuzz/run_afl.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir -p data
|
||||
cp ../data/users.db ./data/users.db
|
||||
mkdir -p configs
|
||||
cp ../configs/config.toml ./configs/config.toml
|
||||
|
||||
mkdir -p fuzz_out
|
||||
|
||||
afl-fuzz -V $(( 60 * 5 )) -i fuzz_in -o fuzz_out -- ./authapp_for_afl
|
||||
10
aflfuzz/run_fuzz.sh
Executable file
10
aflfuzz/run_fuzz.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir -p data
|
||||
cp ../data/users.db ./data/users.db
|
||||
mkdir -p configs
|
||||
cp ../configs/config.toml ./configs/config.toml
|
||||
|
||||
mkdir -p fuzz_out
|
||||
|
||||
afl-fuzz -V $(( 60 * 5 )) -Q -i fuzz_in -o fuzz_out -- ../build/release/authapp
|
||||
62
analysis_report.md
Normal file
62
analysis_report.md
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# Комплексный отчёт об анализе безопасности приложения
|
||||
|
||||
## Среда разработки
|
||||
|
||||
Go версии 1.23, Debian 12.
|
||||
|
||||
## Среда анализа
|
||||
|
||||
Go версии 1.24, Debian 13.
|
||||
|
||||
# Статический анализ (SAST)
|
||||
|
||||
* Bearer - хорошо работает для анализа взаимодействия с ОС, подсветил возможную утечку информации в логах работы приложения и отсутствие проверки пути загрузки конфига.
|
||||
|
||||
* Gosec - ориентирован на поиск проблем с безопасностью, нашёл (как и bearer) проблему с путём загрузки конфига и (в отличие от bearer) предложил способ исправления.
|
||||
|
||||
* Golangci-lint - больше линтер, нежели статический анализатор, указал только на возможную замену if с условием, содержащем "ИЛИ", на switch (я считаю, что это false positive).
|
||||
|
||||
* Svace (svacer) - проприетарный инструмент, который был развёрнут во внутренней сети компании и был также использован, но не был включён в итоги; было одно срабатывание на код самого приложения и достаточно много - на использованные модули; по моему мнению, все срабатывания - false positive.
|
||||
|
||||
Подробные результаты (кроме svace/svacer) см. в директории sast_results.
|
||||
|
||||
# Фаззинг
|
||||
|
||||
* Нативный фаззинг (доступен с версии Go 1.18 и считается стандартом, как дополнение нативного тестирования позволяет визуализировать покрытие кода) - **объектом тестирования** стала функция аутентификации, которая в том числе вызывала функции для доступа к БД и хеширования; **цель фаззинга** - проверка корректности работы функции аутентификации; **входные данные** - строки логина и пароля (начальные данные - правильные и неправильные пары логин-пароль для 2 тестовых пользователей, а также пустые строки в качестве логина и пароля); **отслеживались ошибки**, возвращаемые самой функцией аутентификации, а также неожиданная (не по 2 парам логин-пароль в тестовой базе) успешная аутентификация и аварийное завершение работы.
|
||||
|
||||
* AFL++ в режиме QEMU (универсальный способ проверки готового бинарника, принимающего данные в stdin или из файла) - **объектом тестирования** стала скомпилированная программа; **цель** - проверка устойчивости итогового исполняемого файла к различным входным данным; **начальные входные данные** были как и в нативном фаззинге (корректные строки), но во время фаззинга они мутировали в том числе и в бинарные данные; **отслеживалось** аварийное завершение работы.
|
||||
|
||||
Длительность фаззинга - 6 часов. Ошибок не найдено.
|
||||
|
||||
# Анализ сторонних зависимостей
|
||||
|
||||
Go хорош тем, что не даёт скомпилировать программу при наличии избыточных зависимостей (неиспользованные import считаются ошибкой). Скачать библиотеки можно как из официального репозитория пакетов, так и из пользовательских репозиториев (на github).
|
||||
|
||||
Также система модулей (см. файлы go.mod и go.sum) позволяет зафиксировать версии заимствованных библиотек с использованием хешей как исходного кода самих импортируемых модулей, так и хешей их зависимостей (их go.mod).
|
||||
|
||||
Таким образом, гарантируется автоматическое ведение списка зависимостей, повторяемость сборок и защита от возможных злоумышленных изменений кода сторонних библиотек. В файле go.mod в том числе указывается тип зависимости, а именно приписка indirect у транзитивной зависимости, требующейся для работы прямой зависимости.
|
||||
|
||||
## Список зависимостей
|
||||
|
||||
* github.com/mattn/go-sqlite3 - библиотека для работы с БД SQLite, в которой хранятся данные о пользователях; используется для SQL запросов
|
||||
|
||||
* github.com/pelletier/go-toml/v2 - библиотека для работы с toml файлами, в таком формате хранится конфиг (настройки приложения)
|
||||
|
||||
* golang.org/x/term - библиотека для функций работы с терминалом, используется для скрытия пароля при его вводе
|
||||
|
||||
* golang.org/x/sys - зависимость golang.org/x/term для низкоуровневой работы с ОС
|
||||
|
||||
* а также компоненты стандартной библиотеки Go
|
||||
|
||||
Итого: библиотека term (с зависимостью sys) используется в единственном месте для важной задачи (маскирование вводимого пароля), библиотека go-toml тоже используется для единственной функции (чтение параметров-настроек при запуске приложения для возможности гибкой настройки), библиотека go-sqlite3 используется для модификации поведения стандартной библиотеки database/sql (а именно регистрация драйвера SQLite) и затрагивает все 8 функций в internal/db/sqlite.go.
|
||||
|
||||
## Безопасность зависимостей
|
||||
|
||||
Анализ зависимостей на известные уязвимости с помощью утилиты govulncheck (официальный инструмент, использующий официальную базу уязвимостей) дал такой результат (это именно вызовы уязвимых функций, подробные результаты см. в директории govulncheck):
|
||||
|
||||
Vulnerability #1: GO-2026-4341 Memory exhaustion in query parameter parsing in net/url (More info: https://pkg.go.dev/vuln/GO-2026-4341)
|
||||
|
||||
Vulnerability #2: GO-2025-3849 Incorrect results returned from Rows.Scan in database/sql (More info: https://pkg.go.dev/vuln/GO-2025-3849)
|
||||
|
||||
Your code is affected by 2 vulnerabilities from the Go standard library.
|
||||
This scan also found 4 vulnerabilities in packages you import and 29 vulnerabilities in modules you require, but your code doesn't appear to call these vulnerabilities.
|
||||
BIN
docs/gofuzz.odp
Normal file
BIN
docs/gofuzz.odp
Normal file
Binary file not shown.
BIN
docs/gofuzz.pdf
Normal file
BIN
docs/gofuzz.pdf
Normal file
Binary file not shown.
BIN
docs/gosast.odp
Normal file
BIN
docs/gosast.odp
Normal file
Binary file not shown.
BIN
docs/gosast.pdf
Normal file
BIN
docs/gosast.pdf
Normal file
Binary file not shown.
Binary file not shown.
6
go.mod
6
go.mod
|
|
@ -1,9 +1,13 @@
|
|||
module linux-auth
|
||||
|
||||
go 1.23.0
|
||||
go 1.24.0
|
||||
|
||||
toolchain go1.24.4
|
||||
|
||||
require (
|
||||
github.com/mattn/go-sqlite3 v1.14.33
|
||||
github.com/pelletier/go-toml/v2 v2.2.4
|
||||
golang.org/x/term v0.38.0
|
||||
)
|
||||
|
||||
require golang.org/x/sys v0.39.0 // indirect
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -4,9 +4,5 @@ github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0
|
|||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
||||
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
||||
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
|
||||
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
|
||||
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
|
||||
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
|
||||
|
|
|
|||
39
golang-fuzz/auth_fuzz.go
Normal file
39
golang-fuzz/auth_fuzz.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package my_golang_fuzz
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"linux-auth/internal/auth"
|
||||
"linux-auth/internal/db"
|
||||
)
|
||||
|
||||
func Fuzz(data []byte) int {
|
||||
if err := db.Init("test_data.db"); err != nil {
|
||||
return -1
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
parts := bytes.SplitN(data, []byte{0}, 2)
|
||||
if len(parts) != 2 {
|
||||
return 0
|
||||
}
|
||||
|
||||
username := string(parts[0])
|
||||
password := string(parts[1])
|
||||
|
||||
ok, err := auth.Authenticate(username, password)
|
||||
|
||||
if err != nil {
|
||||
return -1
|
||||
}
|
||||
|
||||
if ok {
|
||||
if (username == "admin" && password == "admin123") ||
|
||||
(username == "user1" && password == "password1") {
|
||||
return 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
return 1
|
||||
}
|
||||
38
golang-fuzz/auth_fuzz_golangfuzz_test.go
Normal file
38
golang-fuzz/auth_fuzz_golangfuzz_test.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// Code generated by golang-fuzz; DO NOT EDIT.
|
||||
|
||||
package my_golang_fuzz
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Fuzz_(f *testing.F) {
|
||||
loadTestCases(f)
|
||||
f.Fuzz(func(_ *testing.T, input []byte) { Fuzz(input) })
|
||||
}
|
||||
|
||||
func loadTestCases(f *testing.F) {
|
||||
dir, err := os.ReadDir(`corpus`)
|
||||
if err != nil {
|
||||
f.Logf(`Running without adding corpus: %s`, err)
|
||||
return
|
||||
}
|
||||
|
||||
if len(dir) == 0 {
|
||||
f.Log(`Running without adding corpus: directory is empty`)
|
||||
}
|
||||
|
||||
for _, corpus := range dir {
|
||||
if corpus.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
input, err := os.ReadFile(filepath.Join(`corpus`, corpus.Name()))
|
||||
if err != nil {
|
||||
f.Logf(`Could not read corpus input %s: %s`, corpus.Name(), err)
|
||||
}
|
||||
f.Add(input)
|
||||
}
|
||||
}
|
||||
3
golang-fuzz/install_golang-fuzz.sh
Executable file
3
golang-fuzz/install_golang-fuzz.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
go install github.com/ultraware/golang-fuzz@latest
|
||||
7
golang-fuzz/run_golang-fuzz.sh
Executable file
7
golang-fuzz/run_golang-fuzz.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
cp ../data/users.db test_data.db
|
||||
|
||||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
|
||||
golang-fuzz -gofuzz -run
|
||||
3
govulncheck/install.sh
Executable file
3
govulncheck/install.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
|
||||
25
govulncheck/results.txt
Normal file
25
govulncheck/results.txt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
=== Symbol Results ===
|
||||
|
||||
Vulnerability #1: GO-2026-4341
|
||||
Memory exhaustion in query parameter parsing in net/url
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4341
|
||||
Standard library
|
||||
Found in: net/url@go1.24.4
|
||||
Fixed in: net/url@go1.24.12
|
||||
Example traces found:
|
||||
#1: internal/db/sqlite.go:32:26: db.Init calls sql.Open, which eventually calls url.ParseQuery
|
||||
|
||||
Vulnerability #2: GO-2025-3849
|
||||
Incorrect results returned from Rows.Scan in database/sql
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-3849
|
||||
Standard library
|
||||
Found in: database/sql@go1.24.4
|
||||
Fixed in: database/sql@go1.24.6
|
||||
Example traces found:
|
||||
#1: internal/db/sqlite.go:89:17: db.GetUser calls sql.Row.Scan
|
||||
|
||||
Your code is affected by 2 vulnerabilities from the Go standard library.
|
||||
This scan also found 4 vulnerabilities in packages you import and 29
|
||||
vulnerabilities in modules you require, but your code doesn't appear to call
|
||||
these vulnerabilities.
|
||||
Use '-show verbose' for more details.
|
||||
8
govulncheck/run.sh
Executable file
8
govulncheck/run.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
export PATH=$PATH:$HOME/go/bin
|
||||
|
||||
govulncheck ../... | tee results.txt
|
||||
printf "\nАнализ известных уязвимостей в использованных библиотечных функциях завершён, результаты на экране продублированы в results.txt\nЗапуск подробного анализа (-show verbose)\n"
|
||||
govulncheck -show verbose ../... > verbose_results.txt
|
||||
printf "\nПодробный анализ завершён, его результаты сохранены в verbose_resulsts.txt\n"
|
||||
290
govulncheck/verbose_results.txt
Normal file
290
govulncheck/verbose_results.txt
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
Fetching vulnerabilities from the database...
|
||||
|
||||
Checking the code against the vulnerabilities...
|
||||
|
||||
The package pattern matched the following 10 root packages:
|
||||
linux-auth/internal/db
|
||||
linux-auth/internal/utils
|
||||
linux-auth/cmd/add_user
|
||||
linux-auth/internal/auth
|
||||
linux-auth/internal/config
|
||||
linux-auth/internal/ui
|
||||
linux-auth/cmd/authapp
|
||||
linux-auth/cmd/init_users
|
||||
linux-auth/golang-fuzz
|
||||
linux-auth/myfuzz
|
||||
Govulncheck scanned the following 5 modules and the go1.24.4 standard library:
|
||||
linux-auth
|
||||
github.com/mattn/go-sqlite3@v1.14.33
|
||||
github.com/pelletier/go-toml/v2@v2.2.4
|
||||
golang.org/x/sys@v0.39.0
|
||||
golang.org/x/term@v0.38.0
|
||||
|
||||
=== Symbol Results ===
|
||||
|
||||
Vulnerability #1: GO-2026-4341
|
||||
Memory exhaustion in query parameter parsing in net/url
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4341
|
||||
Standard library
|
||||
Found in: net/url@go1.24.4
|
||||
Fixed in: net/url@go1.24.12
|
||||
Example traces found:
|
||||
#1: internal/db/sqlite.go:32:26: db.Init calls sql.Open, which eventually calls url.ParseQuery
|
||||
|
||||
Vulnerability #2: GO-2025-3849
|
||||
Incorrect results returned from Rows.Scan in database/sql
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-3849
|
||||
Standard library
|
||||
Found in: database/sql@go1.24.4
|
||||
Fixed in: database/sql@go1.24.6
|
||||
Example traces found:
|
||||
#1: internal/db/sqlite.go:89:17: db.GetUser calls sql.Row.Scan
|
||||
|
||||
=== Package Results ===
|
||||
|
||||
Vulnerability #1: GO-2026-4864
|
||||
TOCTOU permits root escape on Linux via Root.Chmod in os in
|
||||
internal/syscall/unix
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4864
|
||||
Standard library
|
||||
Found in: internal/syscall/unix@go1.24.4
|
||||
Fixed in: internal/syscall/unix@go1.25.9
|
||||
Platforms: linux
|
||||
|
||||
Vulnerability #2: GO-2026-4602
|
||||
FileInfo can escape from a Root in os
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4602
|
||||
Standard library
|
||||
Found in: os@go1.24.4
|
||||
Fixed in: os@go1.25.8
|
||||
|
||||
Vulnerability #3: GO-2026-4601
|
||||
Incorrect parsing of IPv6 host literals in net/url
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4601
|
||||
Standard library
|
||||
Found in: net/url@go1.24.4
|
||||
Fixed in: net/url@go1.25.8
|
||||
|
||||
Vulnerability #4: GO-2025-4010
|
||||
Insufficient validation of bracketed IPv6 hostnames in net/url
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4010
|
||||
Standard library
|
||||
Found in: net/url@go1.24.4
|
||||
Fixed in: net/url@go1.24.8
|
||||
|
||||
=== Module Results ===
|
||||
|
||||
Vulnerability #1: GO-2026-4986
|
||||
Quadratic string concatentation in consumeComment in net/mail
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4986
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #2: GO-2026-4982
|
||||
Bypass of meta content URL escaping causes XSS in html/template
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4982
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #3: GO-2026-4981
|
||||
Crash when handling long CNAME response in net
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4981
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #4: GO-2026-4980
|
||||
Escaper bypass leads to XSS in html/template
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4980
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #5: GO-2026-4977
|
||||
Quadratic string concatenation in consumePhrase in net/mail
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4977
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #6: GO-2026-4976
|
||||
ReverseProxy forwards queries with more than urlmaxqueryparams parameters in
|
||||
net/http/httputil
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4976
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #7: GO-2026-4971
|
||||
Panic in Dial and LookupPort when handling NUL byte on Windows in net
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4971
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #8: GO-2026-4947
|
||||
Unexpected work during chain building in crypto/x509
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4947
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.9
|
||||
|
||||
Vulnerability #9: GO-2026-4946
|
||||
Inefficient policy validation in crypto/x509
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4946
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.9
|
||||
|
||||
Vulnerability #10: GO-2026-4918
|
||||
Infinite loop in HTTP/2 transport when given bad SETTINGS_MAX_FRAME_SIZE in
|
||||
net/http/internal/http2 in golang.org/x/net
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4918
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.10
|
||||
|
||||
Vulnerability #11: GO-2026-4870
|
||||
Unauthenticated TLS 1.3 KeyUpdate record can cause persistent connection
|
||||
retention and DoS in crypto/tls
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4870
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.9
|
||||
|
||||
Vulnerability #12: GO-2026-4869
|
||||
Unbounded allocation for old GNU sparse in archive/tar
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4869
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.9
|
||||
|
||||
Vulnerability #13: GO-2026-4865
|
||||
JsBraceDepth Context Tracking Bugs (XSS) in html/template
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4865
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.9
|
||||
|
||||
Vulnerability #14: GO-2026-4603
|
||||
URLs in meta content attribute actions are not escaped in html/template
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4603
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.25.8
|
||||
|
||||
Vulnerability #15: GO-2026-4342
|
||||
Excessive CPU consumption when building archive index in archive/zip
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4342
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.12
|
||||
|
||||
Vulnerability #16: GO-2026-4340
|
||||
Handshake messages may be processed at the incorrect encryption level in
|
||||
crypto/tls
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4340
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.12
|
||||
|
||||
Vulnerability #17: GO-2026-4337
|
||||
Unexpected session resumption in crypto/tls
|
||||
More info: https://pkg.go.dev/vuln/GO-2026-4337
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.13
|
||||
|
||||
Vulnerability #18: GO-2025-4175
|
||||
Improper application of excluded DNS name constraints when verifying
|
||||
wildcard names in crypto/x509
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4175
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.11
|
||||
|
||||
Vulnerability #19: GO-2025-4155
|
||||
Excessive resource consumption when printing error string for host
|
||||
certificate validation in crypto/x509
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4155
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.11
|
||||
|
||||
Vulnerability #20: GO-2025-4015
|
||||
Excessive CPU consumption in Reader.ReadResponse in net/textproto
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4015
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #21: GO-2025-4014
|
||||
Unbounded allocation when parsing GNU sparse map in archive/tar
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4014
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #22: GO-2025-4013
|
||||
Panic when validating certificates with DSA public keys in crypto/x509
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4013
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #23: GO-2025-4012
|
||||
Lack of limit when parsing cookies can cause memory exhaustion in net/http
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4012
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #24: GO-2025-4011
|
||||
Parsing DER payload can cause memory exhaustion in encoding/asn1
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4011
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #25: GO-2025-4009
|
||||
Quadratic complexity when parsing some invalid inputs in encoding/pem
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4009
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #26: GO-2025-4008
|
||||
ALPN negotiation error contains attacker controlled information in
|
||||
crypto/tls
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4008
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #27: GO-2025-4007
|
||||
Quadratic complexity when checking name constraints in crypto/x509
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4007
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.9
|
||||
|
||||
Vulnerability #28: GO-2025-4006
|
||||
Excessive CPU consumption in ParseAddress in net/mail
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-4006
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.8
|
||||
|
||||
Vulnerability #29: GO-2025-3956
|
||||
Unexpected paths returned from LookPath in os/exec
|
||||
More info: https://pkg.go.dev/vuln/GO-2025-3956
|
||||
Standard library
|
||||
Found in: stdlib@go1.24.4
|
||||
Fixed in: stdlib@go1.24.6
|
||||
|
||||
Your code is affected by 2 vulnerabilities from the Go standard library.
|
||||
This scan also found 4 vulnerabilities in packages you import and 29
|
||||
vulnerabilities in modules you require, but your code doesn't appear to call
|
||||
these vulnerabilities.
|
||||
48
myfuzz/auth_fuzz.go.backup
Normal file
48
myfuzz/auth_fuzz.go.backup
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package myfuzz
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"linux-auth/internal/auth"
|
||||
"linux-auth/internal/db"
|
||||
)
|
||||
|
||||
// Fuzz — это функция, которую будет вызывать go-fuzz.
|
||||
// Принимает только []byte — все входные данные в одном байтовом потоке.
|
||||
func Fuzz(data []byte) int {
|
||||
// Инициализируем БД на каждом вызове — go-fuzz не имеет f.Cleanup()
|
||||
if err := db.Init("test_data.db"); err != nil {
|
||||
return -1 // ошибка инициализации — краш
|
||||
}
|
||||
defer db.Close() // закрываем после каждого вызова
|
||||
|
||||
// Разделяем байты по нулевому байту (\x00) — это разделитель между username и password
|
||||
parts := bytes.SplitN(data, []byte{0}, 2)
|
||||
if len(parts) != 2 {
|
||||
return 0 // недостаточно данных — пропускаем
|
||||
}
|
||||
|
||||
username := string(parts[0])
|
||||
password := string(parts[1])
|
||||
|
||||
ok, err := auth.Authenticate(username, password)
|
||||
|
||||
// Если произошла ошибка — это баг
|
||||
if err != nil {
|
||||
return -1 // краш
|
||||
}
|
||||
|
||||
// Если аутентификация прошла успешно — проверяем, разрешён ли такой вход
|
||||
if ok {
|
||||
// Разрешённые пары (аналогично f.Add)
|
||||
if (username == "admin" && password == "admin123") ||
|
||||
(username == "user1" && password == "password1") {
|
||||
return 1 // норма — это ожидаемый результат
|
||||
}
|
||||
// Неожиданный успешный вход — это баг!
|
||||
return -1 // краш
|
||||
}
|
||||
|
||||
// Неудачная аутентификация — это нормально
|
||||
return 1 // норма
|
||||
}
|
||||
3
myfuzz/build_for_go-fuzz.sh
Executable file
3
myfuzz/build_for_go-fuzz.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
go-fuzz-build -libfuzzer ./myfuzz
|
||||
33
myfuzz/cover.out
Normal file
33
myfuzz/cover.out
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
mode: set
|
||||
linux-auth/internal/auth/auth.go:21.60,23.16 2 1
|
||||
linux-auth/internal/auth/auth.go:23.16,26.3 1 1
|
||||
linux-auth/internal/auth/auth.go:29.2,29.17 1 1
|
||||
linux-auth/internal/auth/auth.go:29.17,31.3 1 0
|
||||
linux-auth/internal/auth/auth.go:34.2,34.55 1 1
|
||||
linux-auth/internal/auth/auth.go:34.55,37.17 2 1
|
||||
linux-auth/internal/auth/auth.go:37.17,39.4 1 0
|
||||
linux-auth/internal/auth/auth.go:42.3,44.41 3 1
|
||||
linux-auth/internal/auth/auth.go:44.41,46.4 1 0
|
||||
linux-auth/internal/auth/auth.go:48.3,48.20 1 1
|
||||
linux-auth/internal/auth/auth.go:52.2,53.18 2 1
|
||||
linux-auth/internal/db/sqlite.go:29.30,33.16 3 1
|
||||
linux-auth/internal/db/sqlite.go:33.16,35.3 1 0
|
||||
linux-auth/internal/db/sqlite.go:38.2,38.39 1 1
|
||||
linux-auth/internal/db/sqlite.go:38.39,40.3 1 0
|
||||
linux-auth/internal/db/sqlite.go:42.2,42.23 1 1
|
||||
linux-auth/internal/db/sqlite.go:48.14,49.21 1 1
|
||||
linux-auth/internal/db/sqlite.go:49.21,51.3 1 1
|
||||
linux-auth/internal/db/sqlite.go:57.27,70.2 3 1
|
||||
linux-auth/internal/db/sqlite.go:77.46,97.26 6 1
|
||||
linux-auth/internal/db/sqlite.go:97.26,99.3 1 1
|
||||
linux-auth/internal/db/sqlite.go:100.2,100.16 1 1
|
||||
linux-auth/internal/db/sqlite.go:100.16,102.3 1 0
|
||||
linux-auth/internal/db/sqlite.go:104.2,105.19 2 1
|
||||
linux-auth/internal/db/sqlite.go:112.43,121.2 3 1
|
||||
linux-auth/internal/db/sqlite.go:127.40,136.2 3 1
|
||||
linux-auth/internal/db/sqlite.go:142.38,151.2 3 0
|
||||
linux-auth/internal/db/sqlite.go:158.54,165.16 3 0
|
||||
linux-auth/internal/db/sqlite.go:165.16,167.3 1 0
|
||||
linux-auth/internal/db/sqlite.go:169.2,169.12 1 0
|
||||
linux-auth/internal/utils/hash.go:13.43,16.2 2 1
|
||||
linux-auth/internal/utils/hash.go:24.48,26.2 1 1
|
||||
3
myfuzz/cover.txt
Normal file
3
myfuzz/cover.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PASS
|
||||
coverage: 75.0% of statements in ../...
|
||||
ok linux-auth/myfuzz 0.046s
|
||||
3
myfuzz/install_go-fuzz.sh
Executable file
3
myfuzz/install_go-fuzz.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
go install github.com/dvyukov/go-fuzz/go-fuzz@latest github.com/dvyukov/go-fuzz/go-fuzz-build@latest
|
||||
37
myfuzz/myfuzz_test.go
Normal file
37
myfuzz/myfuzz_test.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package myfuzz
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"linux-auth/internal/auth"
|
||||
"linux-auth/internal/db"
|
||||
)
|
||||
|
||||
func FuzzAuth(f *testing.F) {
|
||||
err := db.Init("test_data.db")
|
||||
if err != nil {
|
||||
f.Fatalf("DB init error: %v", err)
|
||||
}
|
||||
f.Cleanup(func() {
|
||||
db.Close()
|
||||
})
|
||||
|
||||
f.Add("admin", "admin123") // right admin
|
||||
f.Add("user1", "password1") // right user
|
||||
f.Add("admin", "admin") // wrong admin
|
||||
f.Add("user", "password") // wrong user
|
||||
f.Add("", "") // blank test
|
||||
|
||||
f.Fuzz(func(t *testing.T, username string, password string) {
|
||||
ok, err := auth.Authenticate(username, password)
|
||||
if err != nil {
|
||||
t.Errorf("For username %q and password %q error: %v", username, password, err)
|
||||
}
|
||||
if ok {
|
||||
if (username == "admin" && password == "admin123") || (username == "user1" && password == "password1") {
|
||||
return
|
||||
}
|
||||
t.Errorf("Unexpected login for username %q and password %q", username, password)
|
||||
}
|
||||
})
|
||||
}
|
||||
6
myfuzz/run_fuzz.sh
Executable file
6
myfuzz/run_fuzz.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
cp ../data/users.db test_data.db
|
||||
|
||||
go test -fuzz=FuzzAuth -fuzztime=5m --parallel=1
|
||||
go test -run=FuzzAuth -coverprofile=cover.out -coverpkg=../... | tee cover.txt
|
||||
5
myfuzz/run_go-fuzz.sh
Executable file
5
myfuzz/run_go-fuzz.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
cp ../data/users.db test_data.db
|
||||
|
||||
go-fuzz -bin=myfuzz-fuzz.zip -workdir=work
|
||||
3
myfuzz/view_fuzz_coverage.sh
Executable file
3
myfuzz/view_fuzz_coverage.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
go tool cover -html=cover.out
|
||||
1
sast_results/bearer.sarif
Normal file
1
sast_results/bearer.sarif
Normal file
File diff suppressed because one or more lines are too long
70
sast_results/bearer.txt
Normal file
70
sast_results/bearer.txt
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
|
||||
Security Report
|
||||
|
||||
=====================================
|
||||
|
||||
Rules:
|
||||
https://docs.bearer.com/reference/rules [v0.48.4]
|
||||
|
||||
Language Default Rules Custom Rules Files
|
||||
Go 72 0 8
|
||||
|
||||
|
||||
HIGH: Unsanitized user input in file path [CWE-73]
|
||||
https://docs.bearer.com/reference/rules/go_gosec_filesystem_filereadtaint
|
||||
To ignore this finding, run: bearer ignore add 690cb9207bb6cb72edd1002fae0a0fa3_0
|
||||
|
||||
File: internal/config/config.go:41
|
||||
|
||||
41 data, err := os.ReadFile(path)
|
||||
|
||||
LOW: Leakage of information in logger message [CWE-532]
|
||||
https://docs.bearer.com/reference/rules/go_lang_logger_leak
|
||||
To ignore this finding, run: bearer ignore add 219087ffdfad090e6436320f68eae990_0
|
||||
|
||||
File: cmd/add_user/main.go:33
|
||||
|
||||
33 log.Fatalf("Ошибка инициализации БД: %v\n", err)
|
||||
|
||||
LOW: Leakage of information in logger message [CWE-532]
|
||||
https://docs.bearer.com/reference/rules/go_lang_logger_leak
|
||||
To ignore this finding, run: bearer ignore add 219087ffdfad090e6436320f68eae990_1
|
||||
|
||||
File: cmd/add_user/main.go:41
|
||||
|
||||
41 log.Fatalf("Не удалось создать пользователя %s: %v\n", *username, err)
|
||||
|
||||
LOW: Leakage of information in logger message [CWE-532]
|
||||
https://docs.bearer.com/reference/rules/go_lang_logger_leak
|
||||
To ignore this finding, run: bearer ignore add 533ab12ca2b781f58bc69e81cb601ad6_0
|
||||
|
||||
File: cmd/authapp/main.go:33
|
||||
|
||||
33 log.Fatalf("Ошибка загрузки конфигурации: %v\n", err)
|
||||
|
||||
LOW: Leakage of information in logger message [CWE-532]
|
||||
https://docs.bearer.com/reference/rules/go_lang_logger_leak
|
||||
To ignore this finding, run: bearer ignore add 533ab12ca2b781f58bc69e81cb601ad6_1
|
||||
|
||||
File: cmd/authapp/main.go:43
|
||||
|
||||
43 log.Fatalf("Ошибка инициализации БД: %v\n", err)
|
||||
|
||||
LOW: Leakage of information in logger message [CWE-532]
|
||||
https://docs.bearer.com/reference/rules/go_lang_logger_leak
|
||||
To ignore this finding, run: bearer ignore add 448b1db1ab73e2474723c4d659611644_0
|
||||
|
||||
File: cmd/init_users/main.go:18
|
||||
|
||||
18 log.Fatalf("Ошибка инициализации БД: %v\n", err)
|
||||
=====================================
|
||||
|
||||
72 checks, 6 findings
|
||||
|
||||
CRITICAL: 0
|
||||
HIGH: 1 (CWE-73)
|
||||
MEDIUM: 0
|
||||
LOW: 5 (CWE-532)
|
||||
WARNING: 0
|
||||
|
||||
1
sast_results/golangci-lint.sarif
Normal file
1
sast_results/golangci-lint.sarif
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":"2.1.0","$schema":"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json","runs":[{"tool":{"driver":{"name":"golangci-lint"}},"results":[{"ruleId":"staticcheck","level":"error","message":{"text":"QF1003: could use tagged switch on resp"},"locations":[{"physicalLocation":{"artifactLocation":{"uri":"internal/ui/console.go","index":0},"region":{"startLine":62,"startColumn":3}}}]}]}]}
|
||||
5
sast_results/golangci-lint.txt
Normal file
5
sast_results/golangci-lint.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
internal/ui/console.go:62:3: QF1003: could use tagged switch on resp (staticcheck)
|
||||
if resp == "y" || resp == "yes" {
|
||||
^
|
||||
1 issues:
|
||||
* staticcheck: 1
|
||||
148
sast_results/gosec.sarif
Normal file
148
sast_results/gosec.sarif
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
{
|
||||
"runs": [
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"fixes": [
|
||||
{
|
||||
"artifactChanges": [
|
||||
{
|
||||
"artifactLocation": {
|
||||
"description": {
|
||||
"text": "File requiring changes"
|
||||
}
|
||||
},
|
||||
"replacements": [
|
||||
{
|
||||
"deletedRegion": {
|
||||
"endColumn": 1,
|
||||
"endLine": 1,
|
||||
"startColumn": 1,
|
||||
"startLine": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"description": {
|
||||
"markdown": "Consider using os.Root to scope file access under a fixed root (Go \u003e=1.24). Prefer root.Open/root.Stat over os.Open/os.Stat to prevent directory traversal.",
|
||||
"text": "Consider using os.Root to scope file access under a fixed root (Go \u003e=1.24). Prefer root.Open/root.Stat over os.Open/os.Stat to prevent directory traversal."
|
||||
}
|
||||
}
|
||||
],
|
||||
"level": "error",
|
||||
"locations": [
|
||||
{
|
||||
"physicalLocation": {
|
||||
"artifactLocation": {
|
||||
"uri": "internal/config/config.go"
|
||||
},
|
||||
"region": {
|
||||
"endColumn": 15,
|
||||
"endLine": 41,
|
||||
"snippet": {
|
||||
"text": "data, err := os.ReadFile(path)"
|
||||
},
|
||||
"sourceLanguage": "go",
|
||||
"startColumn": 15,
|
||||
"startLine": 41
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"message": {
|
||||
"text": "Potential file inclusion via variable"
|
||||
},
|
||||
"ruleId": "G304"
|
||||
}
|
||||
],
|
||||
"taxonomies": [
|
||||
{
|
||||
"downloadUri": "https://cwe.mitre.org/data/xml/cwec_v4.4.xml.zip",
|
||||
"guid": "f2856fc0-85b7-373f-83e7-6f8582243547",
|
||||
"informationUri": "https://cwe.mitre.org/data/published/cwe_v4.4.pdf/",
|
||||
"isComprehensive": true,
|
||||
"language": "en",
|
||||
"minimumRequiredLocalizedDataSemanticVersion": "4.4",
|
||||
"name": "CWE",
|
||||
"organization": "MITRE",
|
||||
"releaseDateUtc": "2021-03-15",
|
||||
"shortDescription": {
|
||||
"text": "The MITRE Common Weakness Enumeration"
|
||||
},
|
||||
"taxa": [
|
||||
{
|
||||
"fullDescription": {
|
||||
"text": "The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory."
|
||||
},
|
||||
"guid": "3e718404-88bc-3f17-883e-e85e74078a76",
|
||||
"helpUri": "https://cwe.mitre.org/data/definitions/22.html",
|
||||
"id": "22",
|
||||
"shortDescription": {
|
||||
"text": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version": "4.4"
|
||||
}
|
||||
],
|
||||
"tool": {
|
||||
"driver": {
|
||||
"guid": "8b518d5f-906d-39f9-894b-d327b1a421c5",
|
||||
"informationUri": "https://github.com/securego/gosec/",
|
||||
"name": "gosec",
|
||||
"rules": [
|
||||
{
|
||||
"defaultConfiguration": {
|
||||
"level": "error"
|
||||
},
|
||||
"fullDescription": {
|
||||
"text": "Potential file inclusion via variable"
|
||||
},
|
||||
"help": {
|
||||
"text": "Potential file inclusion via variable\nSeverity: MEDIUM\nConfidence: HIGH\n"
|
||||
},
|
||||
"id": "G304",
|
||||
"name": "Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')",
|
||||
"properties": {
|
||||
"precision": "high",
|
||||
"tags": [
|
||||
"security",
|
||||
"MEDIUM"
|
||||
]
|
||||
},
|
||||
"relationships": [
|
||||
{
|
||||
"kinds": [
|
||||
"superset"
|
||||
],
|
||||
"target": {
|
||||
"guid": "3e718404-88bc-3f17-883e-e85e74078a76",
|
||||
"id": "22",
|
||||
"toolComponent": {
|
||||
"guid": "f2856fc0-85b7-373f-83e7-6f8582243547",
|
||||
"name": "CWE"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"shortDescription": {
|
||||
"text": "Potential file inclusion via variable"
|
||||
}
|
||||
}
|
||||
],
|
||||
"semanticVersion": "2.24.7",
|
||||
"supportedTaxonomies": [
|
||||
{
|
||||
"guid": "f2856fc0-85b7-373f-83e7-6f8582243547",
|
||||
"name": "CWE"
|
||||
}
|
||||
],
|
||||
"version": "2.24.7"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json",
|
||||
"version": "2.1.0"
|
||||
}
|
||||
17
sast_results/gosec.txt
Normal file
17
sast_results/gosec.txt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Results:
|
||||
|
||||
|
||||
[/home/vovuas/linux-auth/internal/config/config.go:41] - G304 (CWE-22): Potential file inclusion via variable (Confidence: HIGH, Severity: MEDIUM)
|
||||
40: func Load(path string) (*Config, error) {
|
||||
> 41: data, err := os.ReadFile(path)
|
||||
42: if err != nil {
|
||||
|
||||
Autofix: Consider using os.Root to scope file access under a fixed root (Go >=1.24). Prefer root.Open/root.Stat over os.Open/os.Stat to prevent directory traversal.
|
||||
|
||||
Summary:
|
||||
Gosec : 2.24.7
|
||||
Files : 8
|
||||
Lines : 545
|
||||
Nosec : 0
|
||||
Issues : 1
|
||||
|
||||
|
|
@ -9,7 +9,10 @@ sudo apt update
|
|||
echo "Установка Go, GCC и SQLite..."
|
||||
sudo apt install -y golang gcc sqlite3 libsqlite3-dev ca-certificates
|
||||
|
||||
echo "Создание директории для хранения БД"
|
||||
mkdir -p data
|
||||
|
||||
echo "Установка Go модулей..."
|
||||
go mod tidy
|
||||
|
||||
echo "Среда готова."
|
||||
echo "Среда готова."
|
||||
|
|
|
|||
30
scripts/config_sast.sh
Normal file
30
scripts/config_sast.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
# --------------------------------------
|
||||
# Настройка SAST анализаторов
|
||||
# --------------------------------------
|
||||
|
||||
echo "Установка curl"
|
||||
sudo apt update
|
||||
sudo apt install -y curl
|
||||
|
||||
echo "Создание директории для результатов анализа"
|
||||
mkdir -p sast_results
|
||||
|
||||
echo "Установка bearer"
|
||||
curl -sfL https://raw.githubusercontent.com/Bearer/bearer/main/contrib/install.sh | sh
|
||||
|
||||
echo "Установка golangci-lint"
|
||||
curl -sSfL https://golangci-lint.run/install.sh | sh -s v2.11.2
|
||||
|
||||
echo "Установка gosec"
|
||||
mkdir -p bin
|
||||
cd bin
|
||||
curl -L -o gosec.tar.gz https://github.com/securego/gosec/releases/download/v2.24.7/gosec_2.24.7_linux_amd64.tar.gz
|
||||
mkdir -p gosec_download
|
||||
tar -xzf gosec.tar.gz -C gosec_download
|
||||
mv gosec_download/gosec .
|
||||
rm -f gosec.tar.gz
|
||||
rm -rf gosec_download
|
||||
chmod +x ./gosec
|
||||
|
||||
echo "Бинарники анализаторов установлены в ./bin"
|
||||
15
scripts/run_sast.sh
Normal file
15
scripts/run_sast.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
# --------------------------------------
|
||||
# Запуск SAST анализа
|
||||
# --------------------------------------
|
||||
|
||||
echo "Запуск bearer"
|
||||
./bin/bearer scan --output sast_results/bearer.txt .
|
||||
|
||||
echo "Запуск golangci-lint"
|
||||
./bin/golangci-lint run > sast_results/golangci-lint.txt
|
||||
|
||||
echo "Запуск gosec"
|
||||
./bin/gosec -out sast_results/gosec.txt ./...
|
||||
|
||||
echo "Анализ завершён, результаты в sast_results"
|
||||
15
scripts/run_sast_sarif.sh
Normal file
15
scripts/run_sast_sarif.sh
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
# --------------------------------------
|
||||
# Запуск SAST анализа
|
||||
# --------------------------------------
|
||||
|
||||
echo "Запуск bearer"
|
||||
./bin/bearer scan --format sarif --output sast_results/bearer.sarif .
|
||||
|
||||
echo "Запуск golangci-lint"
|
||||
./bin/golangci-lint run --output.sarif.path sast_results/golangci-lint.sarif
|
||||
|
||||
echo "Запуск gosec"
|
||||
./bin/gosec -fmt sarif -out sast_results/gosec.sarif ./...
|
||||
|
||||
echo "Анализ завершён, результаты в sast_results"
|
||||
Loading…
Add table
Add a link
Reference in a new issue