-
Notifications
You must be signed in to change notification settings - Fork 0
π‘οΈ Sentinel: [HIGH] Fix ERD DDL Injection vulnerability #373
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
Changes from all commits
09d50a0
d9e6995
4183be7
581e7b2
dd0fb69
2cdfbcb
d1172dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,12 @@ function assertSnakeCaseIdentifier(kind: string, name: string): void { | |
| } | ||
| } | ||
|
|
||
| function assertNoStatementTerminator(value: string): void { | ||
| if (value.includes(';')) { | ||
| throw new Error(`SQL injection prevention: Statement terminators (;) are not allowed.`) | ||
| } | ||
| } | ||
|
|
||
| export class ERDModel { | ||
| private tables: Map<string, Table> = new Map() | ||
|
|
||
|
|
@@ -49,6 +55,7 @@ export class ERDModel { | |
| addColumn(tableName: string, column: Column): void { | ||
| assertSnakeCaseIdentifier('Table', tableName) | ||
| assertSnakeCaseIdentifier('Column', column.name) | ||
| assertNoStatementTerminator(column.type) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π Security & Privacy | π Major | β‘ Quick win DDL μμ± κ²½κ³μμλ
κΆμ₯ μ΅μ λ°©μ΄ const columnDefs = table.columns.map((col) => {
+ assertNoStatementTerminator(col.type)
let def = ` ${col.name} ${col.type}`π€ Prompt for AI Agents |
||
| const table = this.tables.get(tableName) | ||
| if (!table) { | ||
| throw new Error(`Table '${tableName}' does not exist.`) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Security & Privacy | π Major | ποΈ Heavy lift
μΈλ―Έμ½λ‘ κ²μ¬λ§μΌλ‘
column.typeμ DDL μ½μ μ λ§μ μ μμ΅λλ€.generateDDL()μcol.typeμ SQLμ μ§μ μ½μ ν©λλ€. λ°λΌμinteger, is_admin booleanμ²λΌ μΈλ―Έμ½λ‘ μ΄ μλ κ°λ μΆκ° 컬λΌμ μ½μ ν μ μμ΅λλ€.column.typeμ νμ©λ νμ λ¬Έλ²μ allowlist λλ λ¬Έλ² κΈ°λ° κ²μ¦μΌλ‘ μ ννμμμ€. μΈλ―Έμ½λ‘ μ΄ μλ μ½μ κ°μ λν νκ· ν μ€νΈλ μΆκ°νμμμ€.π€ Prompt for AI Agents