Skip to content

feat: add SafeStack detection check#333

Open
model-agent wants to merge 2 commits intomainfrom
feat/issue-301-safestack
Open

feat: add SafeStack detection check#333
model-agent wants to merge 2 commits intomainfrom
feat/issue-301-safestack

Conversation

@model-agent
Copy link
Collaborator

Adds SafeStack detection support for issue #301 by checking for the __safestack_init symbol in ELF symbols/imports/dynamic symbol table.

What changed

  • Added pkg/checksec/SafeStack checker with robust input/error handling.
  • Wired safestack into file checks aggregation (pkg/utils/checks.go).
  • Added SafeStack fields to all output paths via pkg/utils/filePrinter.go:
    • table column
    • json/yaml/xml schema output
  • Added tests:
    • pkg/checksec/safestack_test.go (validation, non-ELF handling, Linux ELF no-safestack path)
    • updated pkg/utils/checks_test.go and pkg/utils/filePrinter_test.go for plumbing coverage.

Validation

  • go test ./... -coverprofile=coverage.out
  • total coverage: 31.2%
  • pkg/checksec/safestack.go coverage:
    • hasSafeStackSymbol: 100%
    • SafeStack: 63.2%

Closes #301.

@augmentcode
Copy link

augmentcode bot commented Feb 19, 2026

🤖 Augment PR Summary

Summary: This PR adds SafeStack detection to checksec by scanning ELF symbol information for the __safestack_init entry point.

Changes:

  • Introduces a new pkg/checksec/safestack.go checker that inspects regular symbols, imported symbols, and the dynamic symbol table.
  • Wires the new safestack check into RunFileChecks aggregation so it’s included in per-file results.
  • Extends structured outputs (JSON/YAML/XML) and the table view to include safestack and safestackColor.
  • Adds/updates tests covering symbol matching, invalid inputs, non-ELF handling, and output plumbing.

Technical Notes: Detection is based on presence of the __safestack_init symbol (including prefixed variants) across multiple ELF symbol sources to support stripped binaries.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add check for SafeStack protection

1 participant