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

SQL server support audit logging queries/RPC calls with NTEXTTYPE parameter #29411

Open
gabrielcorado opened this issue Jul 21, 2023 · 0 comments
Labels
bug database-access Database access related issues and PRs db/sqlserver Microsoft SQL Server related database access issues

Comments

@gabrielcorado
Copy link
Contributor

Currently, SQL Server packets that contain NTEXTTYPE parameters failed to be parsed, causing their contents to be audit logged as db.session.malformed_packet instead of proper db.session.query or db.session.sqlserver.rpc_request. This is mainly due to the go-mssql parsing expecting a different data format (tablename and ROW).

Here is an example of an RPC call (SP_ExecuteSql) from Azure Data Studio that has its SQL parameter as NTEXTTYPE:

03 04 10 00 00 00 01 00                                           // Packet headers
16 00 00 00 12 00 00 00 02 00 00 00 00 00 00 00 00 00 01 00 00 00 // ALL_HEADERS
ff ff                                                             // Proc length
0a 00                                                             // ProcID (SP_ExecuteSql)
02 00                                                             // Option flags
00                                                                // Parameter name (empty)
00                                                                // Status flags
63                                                                // NTEXTTYPE type
66 23 00 00                                                       // NTEXTTYPE length (LONGLEN)
09 04 d0 00 00                                                    // Parameter collation
66 23 00 00                                                       // NTEXTTYPE length

// NTEXT contents start...
53 00 45 00 4c 00 45 00 43 00 54 00 // "SELECT"
@gabrielcorado gabrielcorado added bug database-access Database access related issues and PRs db/sqlserver Microsoft SQL Server related database access issues labels Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug database-access Database access related issues and PRs db/sqlserver Microsoft SQL Server related database access issues
Projects
None yet
Development

No branches or pull requests

1 participant