```ts const validModel = ['gpt-4o-mini', 'gpt-4o-mini-2024-07-18', 'gpt-4o', 'gpt-4o-2024-08-06', 'g

const validModel = ['gpt-4o-mini', 'gpt-4o-mini-2024-07-18', 'gpt-4o', 'gpt-4o-2024-08-06', 'gpt-3.5-turbo-0125', 'gpt-3.5-turbo-1106']; // NO o1-mini
export default class extends WorkerEntrypoint<Env> {
    async fetch(request: Request): Promise<Response> {
        const { model, messages }: any = await request.json();
        return this.rpc(model, messages);
    }

    async rpc(_model: string, messages: Messages[], colo?: string): Promise<Response> {
        const model = _model?.split('/')[1]; // slice prefix openai/
        if (!model || !validModel.includes(model)) {
            return new Response(JSON.stringify({ message: 'Invalid model' }), { status: 400 });
        }

...
        const aiPayload = {
            model: model,
            messages: messages,
            max_tokens: 2048,
            stream: true
        }
...
        const response = await fetch(cfGateway, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${token}`
            },
            body: JSON.stringify(aiPayload),

        });


Someone from Russia was trying to break my backend worker with model o1-mini
My worker is private without public endpoint, which is invoked by service binding via rpc.

I can't understand how this happens.
How o1-mini can bypass my validModel check.

The image is shot from logs AI gateway dashboard.

Any potential vulnerable here?
Screenshot_2024-10-03_at_02.22.21.jpg
Was this page helpful?