Giter VIP home page Giter VIP logo

Comments (3)

andrewkroh avatar andrewkroh commented on June 15, 2024

Thanks for reporting this. We should get this added to the log samples in auparse/testdata. And enhance the hex to ASCII conversion with a post-decode check as you have described. Would you be interested in opening a PR?

from go-libaudit.

sfines avatar sfines commented on June 15, 2024

I've sort of fixed it.. I say sort of because auditd is inconsistent when it encodes data in that field and when it doesn't. I did the following:

func hexToASCII(h string) (string, error) {

	output, err := hex.DecodeString(h)

	nullTerm := bytes.Index(output, []byte{0})
	if nullTerm != -1 {
		output = output[:nullTerm]
	}

	acceptChar := func(r rune) bool {
		return !unicode.IsLetter(r) && !unicode.IsDigit(r) && !unicode.IsPunct(r) && !unicode.IsSpace(r) && !unicode.IsControl(r)
	}

	s_res := strings.IndexFunc(string(output), acceptChar)
	if s_res != -1 {
		return h, errors.New("Not Hex Encoded")
	} else {
		return string(output), err
	}
}

I'm not thinking that's going to scale to super high loads, but it is a start.

from go-libaudit.

andrewkroh avatar andrewkroh commented on June 15, 2024

The hex encoded argument values are not quoted. So I will investigate make a change that uses this as a cue. In the messages below notice how the second message's a2 value is not quoted.

type=EXECVE msg=audit(1491863086.221:1050925): argc=5 a0="grep" a1="--color=auto" a2="-e" a3="[:alpha:]" a4="/etc/passwd"
type=EXECVE msg=audit(1491946471.575:1075898): argc=3 a0="jq" a1="." a2=7B0A202020202020202022646576223A202230383A3031222C0A202020202020202022696E6F6465223A20223139353439363436222C0A2020202020202020226974656D223A202230222C0A2020202020202020226D6F6465223A202230313030373735222C0A2020202020202020226E616D65223A20222F7573722F62696E2F6A71222C0A2020202020202020226F626A223A2022756E636F6E66696E65645F753A6F626A6563745F723A757365725F686F6D655F743A7330222C0A2020202020202020226F626A74797065223A20224E4F524D414C222C0A2020202020202020226F676964223A202231303031222C0A2020202020202020226F756964223A202231303030222C0A2020202020202020227261775F6D657373616765223A2022617564697428313439313934363239362E3735373A31303735383334293A206974656D3D30206E616D653D5C222F7573722F62696E2F6A715C2220696E6F64653D3139353439363436206465763D30383A3031206D6F64653D30313030373735206F7569643D31303030206F6769643D3130303120726465763D30303A3030206F626A3D756E636F6E66696E65645F753A6F626A6563745F723A757365725F686F6D655F743A7330206F626A747970653D4E4F524D414C222C0A20202020202020202272646576223A202230303A3030222C0A2020202020202020227265636F72645F74797065223A202250415448222C0A20202020202020202273657175656E6365223A20313037353833340A2020202020207D

Additionally, the kernel only encodes values with upper-case hex. So we can omit decoding data that contains lower-case characters.

I investigated an approach that checks if the decoded data contains special characters (as per audit_string_contains_control()), but that isn't sufficient to handle all cases.

from go-libaudit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.