fix(security): redact integration secrets from viewer-accessible endpoints
Prevent low-privileged tenant members from reading raw API keys and infrastructure credentials via tenant profile, KV config, model/MCP/web search listings, and KB initialization config responses.
This commit is contained in:
@@ -1385,10 +1385,8 @@ func (h *InitializationHandler) buildConfigResponse(ctx context.Context, models
|
||||
}
|
||||
// Hide sensitive information for builtin models
|
||||
baseURL := model.Parameters.BaseURL
|
||||
apiKey := model.Parameters.APIKey
|
||||
if model.IsBuiltin {
|
||||
baseURL = ""
|
||||
apiKey = ""
|
||||
}
|
||||
|
||||
switch model.Type {
|
||||
@@ -1397,22 +1395,28 @@ func (h *InitializationHandler) buildConfigResponse(ctx context.Context, models
|
||||
"source": string(model.Source),
|
||||
"modelName": model.Name,
|
||||
"baseUrl": baseURL,
|
||||
"apiKey": apiKey,
|
||||
"credentials": map[string]bool{
|
||||
"apiKey": model.Parameters.APIKey != "" && !model.IsBuiltin,
|
||||
},
|
||||
}
|
||||
case types.ModelTypeEmbedding:
|
||||
config["embedding"] = map[string]interface{}{
|
||||
"source": string(model.Source),
|
||||
"modelName": model.Name,
|
||||
"baseUrl": baseURL,
|
||||
"apiKey": apiKey,
|
||||
"dimension": model.Parameters.EmbeddingParameters.Dimension,
|
||||
"credentials": map[string]bool{
|
||||
"apiKey": model.Parameters.APIKey != "" && !model.IsBuiltin,
|
||||
},
|
||||
}
|
||||
case types.ModelTypeRerank:
|
||||
config["rerank"] = map[string]interface{}{
|
||||
"enabled": true,
|
||||
"modelName": model.Name,
|
||||
"baseUrl": baseURL,
|
||||
"apiKey": apiKey,
|
||||
"credentials": map[string]bool{
|
||||
"apiKey": model.Parameters.APIKey != "",
|
||||
},
|
||||
}
|
||||
case types.ModelTypeVLLM:
|
||||
if config["multimodal"] == nil {
|
||||
@@ -1424,9 +1428,11 @@ func (h *InitializationHandler) buildConfigResponse(ctx context.Context, models
|
||||
multimodal["vlm"] = map[string]interface{}{
|
||||
"modelName": model.Name,
|
||||
"baseUrl": baseURL,
|
||||
"apiKey": apiKey,
|
||||
"interfaceType": model.Parameters.InterfaceType,
|
||||
"modelId": model.ID,
|
||||
"credentials": map[string]bool{
|
||||
"apiKey": model.Parameters.APIKey != "" && !model.IsBuiltin,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1450,7 +1456,9 @@ func (h *InitializationHandler) buildConfigResponse(ctx context.Context, models
|
||||
"enabled": false,
|
||||
"modelName": "",
|
||||
"baseUrl": "",
|
||||
"apiKey": "",
|
||||
"credentials": map[string]bool{
|
||||
"apiKey": false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1485,12 +1493,14 @@ func (h *InitializationHandler) buildConfigResponse(ctx context.Context, models
|
||||
switch effectiveProvider {
|
||||
case "cos":
|
||||
multimodal["cos"] = map[string]interface{}{
|
||||
"secretId": kb.StorageConfig.SecretID,
|
||||
"secretKey": kb.StorageConfig.SecretKey,
|
||||
"region": kb.StorageConfig.Region,
|
||||
"bucketName": kb.StorageConfig.BucketName,
|
||||
"appId": kb.StorageConfig.AppID,
|
||||
"pathPrefix": kb.StorageConfig.PathPrefix,
|
||||
"credentials": map[string]bool{
|
||||
"secretId": kb.StorageConfig.SecretID != "",
|
||||
"secretKey": kb.StorageConfig.SecretKey != "",
|
||||
},
|
||||
}
|
||||
case "minio":
|
||||
multimodal["minio"] = map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user