Skip to content

proposal: runtime audit hooks #75059

@mwriter

Description

@mwriter

Proposal Details

Recently, there have been more and more news like
https://socket.dev/blog/11-malicious-go-packages-distribute-obfuscated-remote-payloads
or
https://alexandear.github.io/posts/2025-02-28-malicious-go-programs/
etc
I propose to implement at the api level the ability to monitor and modify a variety of system calls.
Following the example of how it's already done in python
https://docs.python.org/3/library/audit_events.html
But it's done very poorly there, and it would be useful to implement a full-fledged hook subsystem like

audit.Handle(os.RemoveAll, func(path string) error {
    fmt.Println("Path remove request for:", path)
    switch path {
        case "/bin":
            return nil // deny
        case "/tmp/old":
            return os.Rename(path, "/tmp/new") // replace call
        case "/home":
            path = "/tmp/trash" // replace argument
    }
    return os.RemoveAll(path)
})

or

audit.Handle(http.Get, func(url string) (resp *http.Response, err error) {
    fmt.Println("Http get request for:", url)
    switch url {
        case "some.malware.host":
            return nil, nil
        default:
            url = "http://127.0.0.1:8080"
    }
    return http.Get(url)
})

All this can be done anyway if start inject handler code directly in the golang source code, but why spoil it if you can add a separate powerful subsystem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LanguageProposalIssues describing a requested change to the Go language specification.Proposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions