Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
github.com/maruel/circular
Package circular implements an efficient thread-safe circular byte buffer to keep in-memory logs. It implements both io.Writer and io.WriterTo.
This permits keeping all the output in case of a panic() on disk. Note that panic() output itself is only written to stderr since it uses print() builtin.
import (
"log"
"net/http"
"sync"
"github.com/maruel/circular"
)
func main() {
logBuffer := circular.New(10 * 1024 * 1024)
defer func() {
// Flush ensures all readers have caught up.
logBuffer.Flush()
// Close gracefully closes the readers.
logBuffer.Close()
}()
f, err := os.OpenFile("app.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
if err != nil {
panic(err)
}
defer f.Close()
// Send to both circular buffer and file.
log.SetOutput(io.MultiWriter(logBuffer, f))
// Asynchronously write to stderr.
go logBuffer.WriteTo(os.Stderr)
log.Printf("This line is served over HTTP; file and stderr")
http.HandleFunc("/",
func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
// Streams the log buffer over HTTP until Close() is called.
// AutoFlush ensures the log is not buffered locally indefinitely.
logBuffer.WriteTo(circular.AutoFlush(w, time.Second))
})
http.ListenAndServe(":6060", nil)
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.