File tree Expand file tree Collapse file tree 1 file changed +31
-2
lines changed
Expand file tree Collapse file tree 1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,22 @@ const FORBIDDEN_OPERATIONS = [
114114 'TRIGGER' ,
115115 'EVENT' ,
116116 'ROUTINE' ,
117+ // ClickHouse-specific dangerous functions
118+ 'HOSTNAME' ,
119+ 'FQDN' ,
120+ 'VERSION' ,
121+ 'UPTIME' ,
122+ 'GETOSKERNEL' ,
123+ 'GETCPUCOUNT' ,
124+ 'GETMEMORYSIZE' ,
125+ 'READFILE' ,
126+ 'WRITEFILE' ,
127+ 'FILESYSTEM' ,
128+ 'DICTGET' ,
129+ 'REMOTE' ,
130+ 'CLUSTER' ,
131+ 'SHARD' ,
132+ 'REPLICA' ,
117133] ;
118134
119135const FORBIDDEN_PATTERNS = [
@@ -129,6 +145,20 @@ const FORBIDDEN_PATTERNS = [
129145 / \b I N T O \s + (?: O U T F I L E | D U M P F I L E ) \b / gi,
130146 / \b E X T R A C T V A L U E \s * \( / gi,
131147 / \b U P D A T E X M L \s * \( / gi,
148+ // ClickHouse system table access patterns
149+ / \b F R O M \s + s y s t e m \. / gi,
150+ / \b J O I N \s + s y s t e m \. / gi,
151+ / \b i n f o r m a t i o n _ s c h e m a \. / gi,
152+ / \b d e f a u l t \. / gi,
153+ // Dangerous ClickHouse functions
154+ / \b u r l \s * \( / gi,
155+ / \b f i l e \s * \( / gi,
156+ / \b s 3 \s * \( / gi,
157+ / \b h d f s \s * \( / gi,
158+ / \b m y s q l \s * \( / gi,
159+ / \b p o s t g r e s q l \s * \( / gi,
160+ / \b r e m o t e \s * \( / gi,
161+ / \b c l u s t e r \s * \( / gi,
132162] ;
133163
134164const ALLOWED_TABLES = [
@@ -595,7 +625,6 @@ export const customSQL = new Elysia({ prefix: '/v1/custom-sql' })
595625 executionTime : result . execution_time || null ,
596626 rowsRead : result . rows_read || null ,
597627 clientId : body . clientId ,
598- apiKeyId : apiKey . id ,
599628 } ,
600629 } ;
601630 } catch ( error ) {
@@ -614,7 +643,7 @@ export const customSQL = new Elysia({ prefix: '/v1/custom-sql' })
614643 return {
615644 success : false ,
616645 error :
617- error instanceof Error ? error . message : 'Query execution failed ',
646+ 'Query execution failed. Please check your query syntax and try again. ',
618647 code : 'EXECUTION_ERROR' ,
619648 } ;
620649 }
You can’t perform that action at this time.
0 commit comments