Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent "session.start" from being overwritten by "session.exec" #19450

Merged
merged 5 commits into from
Dec 19, 2022

Conversation

rosstimothy
Copy link
Contributor

The session.exec event was not being passed through the session recorder, which resulted in said event having an event index of 0. This caused the original session.start event which also has an eid of 0 to be overwritten by the session.exec event.

By emitting the session.exec event via the same mechanism as the session.start event it gets a proper event index and no longer overwrites the session.start.

Closes #13622

The `session.exec` event was not being passed through the session
recorder, which resulted in said event having an event index of 0.
This caused the original `session.start` event which also has an
`eid` of 0 to be overwritten by the `session.exec` event.

By emitting the `session.exec` event via the same mechanism as the
`session.start` event it gets a proper event index and no longer
overwrites the `session.start`.

Closes #13622
@rosstimothy rosstimothy force-pushed the tross/fix_missing_session_start branch from e3c397c to d3e019a Compare December 16, 2022 20:48
@rosstimothy rosstimothy marked this pull request as ready for review December 16, 2022 21:44
@@ -436,13 +436,14 @@ func emitExecAuditEvent(ctx *ServerContext, cmd string, execErr error) {
scpEvent.Code = events.SCPDownloadCode
}
}
if err := ctx.srv.EmitAuditEvent(ctx.srv.Context(), scpEvent); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For now I think the best we can do is add a comment.

// use ctx.srv instead of ctx.session to emit the event to ensure that it gets recorded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comments in 70c568e indicating the session emitter is recorded and the context emitter is not.

@rosstimothy rosstimothy enabled auto-merge (squash) December 19, 2022 19:18
@rosstimothy rosstimothy merged commit 6ed5185 into master Dec 19, 2022
@github-actions
Copy link

@rosstimothy See the table below for backport results.

Branch Result
branch/v10 Create PR
branch/v11 Create PR
branch/v9 Failed

@rosstimothy rosstimothy deleted the tross/fix_missing_session_start branch December 19, 2022 21:19
rosstimothy added a commit that referenced this pull request Dec 19, 2022
)

The `session.exec` event was not being passed through the session
recorder, which resulted in said event having an event index of 0.
This caused the original `session.start` event which also has an
`eid` of 0 to be overwritten by the `session.exec` event.

By emitting the `session.exec` event via the same mechanism as the
`session.start` event it gets a proper event index and no longer
overwrites the `session.start`.

Closes #13622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disappearing session.start event when using tsh ssh command execution
3 participants